Class: Devformance::TestFramework::Minitest
- Defined in:
- lib/devformance/test_framework/minitest.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #classify_line(line) ⇒ Object
- #discover_files ⇒ Object
- #extract_coverage(line) ⇒ Object
- #file_pattern ⇒ Object
- #name ⇒ Object
- #parse_summary(output) ⇒ Object
- #run_command(file_path, coverage: false) ⇒ Object
- #runner_command ⇒ Object
- #test_terminal_command(file_path) ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from Devformance::TestFramework::Base
Instance Method Details
#classify_line(line) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/devformance/test_framework/minitest.rb', line 42 def classify_line(line) if line.match?(/(\d+)\s+tests?,\s+(\d+)\s+assertions?/) "summary" elsif line.match?(/^\s*\.+\s/) || line.include?("PASS") "pass" elsif line.match?(/^\s*[FE]+\s/) || line.include?("FAIL") || line.include?("ERROR") "fail" elsif line.include?("SKIP") "pending" elsif line.match?(/Line Coverage:\s*([\d.]+)%/) "coverage" else "info" end end |
#discover_files ⇒ Object
10 11 12 |
# File 'lib/devformance/test_framework/minitest.rb', line 10 def discover_files @discover_files ||= Dir.glob(root_path.join(file_pattern)).sort end |
#extract_coverage(line) ⇒ Object
58 59 60 |
# File 'lib/devformance/test_framework/minitest.rb', line 58 def extract_coverage(line) line.match(/Line Coverage:\s*([\d.]+)%/)&.[](1)&.to_f end |
#file_pattern ⇒ Object
6 7 8 |
# File 'lib/devformance/test_framework/minitest.rb', line 6 def file_pattern "test/integration/*_test.rb" end |
#name ⇒ Object
62 63 64 |
# File 'lib/devformance/test_framework/minitest.rb', line 62 def name "Minitest" end |
#parse_summary(output) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/devformance/test_framework/minitest.rb', line 22 def parse_summary(output) if output =~ /(\d+)\s+tests?,\s+(\d+)\s+assertions?,\s+(\d+)\s+failures?(?:,\s+(\d+)\s+errors?)?(?:,\s+(\d+)\s+skips?)?/m tests = $1.to_i failures = $3.to_i errors = $4.to_i rescue 0 skips = $5.to_i rescue 0 passes = tests - failures - errors - skips { examples: tests, failures: failures + errors, pending: skips, passes: passes } elsif output =~ /(\d+)\s+runs?,\s+(\d+)\s+assertions?,\s+(\d+)\s+failures?(?:,\s+(\d+)\s+errors?)?(?:,\s+(\d+)\s+skips?)?/m runs = $1.to_i failures = $3.to_i errors = $4.to_i rescue 0 skips = $5.to_i rescue 0 passes = runs - failures - errors - skips { examples: runs, failures: failures + errors, pending: skips, passes: passes } else { examples: 0, failures: 0, pending: 0, passes: 0 } end end |
#run_command(file_path, coverage: false) ⇒ Object
14 15 16 |
# File 'lib/devformance/test_framework/minitest.rb', line 14 def run_command(file_path, coverage: false) [ "bundle", "exec", "rails", "test", "-vc", file_path ] end |
#runner_command ⇒ Object
18 19 20 |
# File 'lib/devformance/test_framework/minitest.rb', line 18 def runner_command "bundle exec rails test -vc" end |
#test_terminal_command(file_path) ⇒ Object
66 67 68 |
# File 'lib/devformance/test_framework/minitest.rb', line 66 def test_terminal_command(file_path) "bundle exec rails test #{file_path}" end |