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
karl-loris-0.0.10 lib/tasks/jspec/jspec_parser.rb
karl-loris-0.0.11 lib/tasks/jspec/jspec_parser.rb
loris-0.5.2 lib/tasks/jspec/jspec_parser.rb
loris-0.5.1 lib/tasks/jspec/jspec_parser.rb
loris-0.5.0 lib/tasks/jspec/jspec_parser.rb
loris-0.4.1 lib/tasks/jspec/jspec_parser.rb
loris-0.4.0 lib/tasks/jspec/jspec_parser.rb
loris-0.3.2 lib/tasks/jspec/jspec_parser.rb
loris-0.3.1 lib/tasks/jspec/jspec_parser.rb
loris-0.3.0 lib/tasks/jspec/jspec_parser.rb
loris-0.2.3 lib/tasks/jspec/jspec_parser.rb
loris-0.2.2 lib/tasks/jspec/jspec_parser.rb
loris-0.2.1 lib/tasks/jspec/jspec_parser.rb
loris-0.2.0 lib/tasks/jspec/jspec_parser.rb
loris-0.1.7 lib/tasks/jspec/jspec_parser.rb
loris-0.1.5 lib/tasks/jspec/jspec_parser.rb
loris-0.1.4 lib/tasks/jspec/jspec_parser.rb
loris-0.1.3 lib/tasks/jspec/jspec_parser.rb
loris-0.1.2 lib/tasks/jspec/jspec_parser.rb
loris-0.1.1 lib/tasks/jspec/jspec_parser.rb