Class: JsTestDriverParser

Inherits:
Object
  • Object
show all
Defined in:
lib/tasks/js_test_driver/js_test_driver_parser.rb

Instance Method Summary collapse

Instance Method Details

#parse_result(detail) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/tasks/js_test_driver/js_test_driver_parser.rb', line 3

def parse_result(detail)
  summary_line = detail.grep( /Total \d+ tests/ )[0]
  
  if summary_line.nil?
    # error
    error_info = (detail + "\nUnknown Error!").to_a[0].strip
    return :error, 'Error', error_info
  end

  if summary_line =~ /Total 0 tests/
    return :error, 'No Tests Run', 'You may not have a browser connected to JS Test Driver'
  end    
  
  if summary_line =~ /Errors: ([1-9]+)/
    num_errors = $1
    error_info = detail.grep(/error \([0-9]+.[0-9]+ ms\)/)[0].strip
    return :failure, num_errors + ' Errors', error_info
  end

  if summary_line =~ /Fails: ([1-9]+)/
    num_failures = $1
    error_info = detail.grep(/failed \([0-9]+.[0-9]+ ms\)/)[0].strip
    return :failure, num_failures + ' Failures', error_info
  end

  return :success, 'All tests pass', ''
  
end