Class: RSpecParser

Inherits:
Object
  • Object
show all
Defined in:
lib/tasks/rspec/rspec_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
# File 'lib/tasks/rspec/rspec_parser.rb', line 3

def parse_result(detail)
  summary_line = detail.grep( /\d+ examples?, \d+ failures?/ )[0]
  
  if summary_line.nil?
    # error
    error_info = (detail + "\nUnknown Error!").to_a[0].strip
    return :error, 'Error', error_info
  end
  
  if summary_line =~ /([1-9]+) failures?/
    num_errors = $1
    
    items = detail.split("\n\n")
    
    error_info = items[1].split("\n")[1]
    return :failure, num_errors + ' Errors', error_info
  end

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