Class: FlakeySpecCatcher::RspecResult::RSpecFailure
- Inherits:
-
Object
- Object
- FlakeySpecCatcher::RspecResult::RSpecFailure
- Defined in:
- lib/flakey_spec_catcher/rspec_result.rb
Overview
Simple class to contain failed example data
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#exception_message ⇒ Object
readonly
Returns the value of attribute exception_message.
-
#spec_start_times ⇒ Object
readonly
Returns the value of attribute spec_start_times.
Instance Method Summary collapse
- #add_failure(spec_start_time = nil) ⇒ Object
- #failure_summary ⇒ Object
-
#initialize(exception_message, spec_start_time = nil) ⇒ RSpecFailure
constructor
A new instance of RSpecFailure.
Constructor Details
#initialize(exception_message, spec_start_time = nil) ⇒ RSpecFailure
Returns a new instance of RSpecFailure.
61 62 63 64 65 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 61 def initialize(, spec_start_time = nil) = @count = 1 @spec_start_times = [spec_start_time].compact end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
59 60 61 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 59 def count @count end |
#exception_message ⇒ Object (readonly)
Returns the value of attribute exception_message.
59 60 61 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 59 def end |
#spec_start_times ⇒ Object (readonly)
Returns the value of attribute spec_start_times.
59 60 61 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 59 def spec_start_times @spec_start_times end |
Instance Method Details
#add_failure(spec_start_time = nil) ⇒ Object
67 68 69 70 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 67 def add_failure(spec_start_time = nil) @count += 1 @spec_start_times.push(spec_start_time) unless spec_start_time.nil? end |
#failure_summary ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 72 def failure_summary summary = "#{count.to_s.indent(2)} times with exception message:\n" summary += .indent(4).red.to_s return summary if spec_start_times.empty? summary += "\n\nFailed at the following times:\n".indent(2) summary += spec_start_times.map { |time| time.indent(4).yellow.to_s }.join("\n").to_s summary end |