class FlakeySpecCatcher::RspecResult
RspecResult
class
Organizes results for a changed test (spec).
Each changed test will have one RspecResult
created for it and for each re-run of that spec, the results will be pushed to the RspecResult
object. This class will then organize and output the results accordingly.
Attributes
description[RW]
location[RW]
total_failures[RW]
total_times_run[RW]
Public Class Methods
new(description, location, exception_message = nil)
click to toggle source
# File lib/flakey_spec_catcher/rspec_result.rb, line 17 def initialize(description, location, exception_message = nil) @description = description @location = location @total_times_run = 1 @total_failures = exception_message ? 1 : 0 @failures = [] add_failure(exception_message) if exception_message end
Public Instance Methods
add_failure(exception_message)
click to toggle source
# File lib/flakey_spec_catcher/rspec_result.rb, line 35 def add_failure(exception_message) failure = @failures.find { |f| f.exception_message == exception_message } failure ? failure.add_failure : @failures.push(RSpecFailure.new(exception_message)) end
add_run(exception_message = nil)
click to toggle source
# File lib/flakey_spec_catcher/rspec_result.rb, line 26 def add_run(exception_message = nil) @total_times_run += 1 return unless exception_message @total_failures += 1 add_failure(exception_message) end
print_results()
click to toggle source
# File lib/flakey_spec_catcher/rspec_result.rb, line 40 def print_results puts "\n#{@description.yellow} (#{location}) \nFAILED #{total_failures} / #{total_times_run} times" @failures.each do |f| puts "#{f.count.to_s.indent(2)} times with exception message:" puts f.exception_message.indent(4).red.to_s end end