Sha256: 2dcd360fe411487a06ef3e8d1d6a4a7cbacb95aeb7d38b9a8f05774680d3c795

Contents?: true

Size: 771 Bytes

Versions: 25

Compression:

Stored size: 771 Bytes

Contents

class JSpecParser
 
  def parse_result(detail)
    summary_line = detail.grep( /Passes:/ )[0]
    
    if summary_line.nil?
      # error
      error_info = (detail + "\nUnknown Error!").to_a[0]
      return :error, 'Error', error_info
    end
    
    # remove console colour information and trim start and end white space
    summary_line = remove_colour(summary_line).strip
    
    if summary_line =~ /Failures:\s+([1-9]+)\d*/
      num_failures = $1
      error_line = detail.grep(/\[31m/)[1] || ''
      error_info = remove_colour(error_line).strip
      return :failure, num_failures + ' Failures', error_info
    end

    
    return :success, 'All Passed', summary_line
  end
  
  def remove_colour(string)
    return string.gsub(/\e\[[0-9]+m?/, '')
  end
  
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
loris-0.1.0 lib/tasks/jspec/jspec_parser.rb
loris-0.0.16 lib/tasks/jspec/jspec_parser.rb
loris-0.0.15 lib/tasks/jspec/jspec_parser.rb
loris-0.0.14 lib/tasks/jspec/jspec_parser.rb
loris-0.0.12 lib/tasks/jspec/jspec_parser.rb