Class: FlakeySpecCatcher::RspecResult
- Inherits:
-
Object
- Object
- FlakeySpecCatcher::RspecResult
- Defined in:
- lib/flakey_spec_catcher/rspec_result.rb
Overview
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.
Defined Under Namespace
Classes: RSpecFailure
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#failures ⇒ Object
readonly
Returns the value of attribute failures.
-
#location ⇒ Object
Returns the value of attribute location.
-
#spec_start_times ⇒ Object
readonly
Returns the value of attribute spec_start_times.
-
#total_failures ⇒ Object
Returns the value of attribute total_failures.
-
#total_times_run ⇒ Object
Returns the value of attribute total_times_run.
Instance Method Summary collapse
- #add_failure(exception_message) ⇒ Object
- #add_run(exception_message = nil) ⇒ Object
- #current_spec_start_time ⇒ Object
-
#initialize(description, location, spec_start_times, exception_message = nil) ⇒ RspecResult
constructor
A new instance of RspecResult.
- #print_results ⇒ Object
Constructor Details
#initialize(description, location, spec_start_times, exception_message = nil) ⇒ RspecResult
Returns a new instance of RspecResult.
18 19 20 21 22 23 24 25 26 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 18 def initialize(description, location, spec_start_times, = nil) @description = description @location = location @total_times_run = 1 @total_failures = ? 1 : 0 @failures = [] @spec_start_times = spec_start_times add_failure() if end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
15 16 17 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 15 def description @description end |
#failures ⇒ Object (readonly)
Returns the value of attribute failures.
16 17 18 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 16 def failures @failures end |
#location ⇒ Object
Returns the value of attribute location.
15 16 17 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 15 def location @location end |
#spec_start_times ⇒ Object (readonly)
Returns the value of attribute spec_start_times.
16 17 18 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 16 def spec_start_times @spec_start_times end |
#total_failures ⇒ Object
Returns the value of attribute total_failures.
15 16 17 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 15 def total_failures @total_failures end |
#total_times_run ⇒ Object
Returns the value of attribute total_times_run.
15 16 17 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 15 def total_times_run @total_times_run end |
Instance Method Details
#add_failure(exception_message) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 37 def add_failure() failure = @failures.find { |f| f. == } if failure failure.add_failure(current_spec_start_time) else @failures.push(RSpecFailure.new(, current_spec_start_time)) end end |
#add_run(exception_message = nil) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 28 def add_run( = nil) @total_times_run += 1 return unless @total_failures += 1 add_failure() end |
#current_spec_start_time ⇒ Object
46 47 48 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 46 def current_spec_start_time @spec_start_times[@total_times_run - 1] end |
#print_results ⇒ Object
50 51 52 53 54 55 |
# File 'lib/flakey_spec_catcher/rspec_result.rb', line 50 def print_results puts "\n#{@description.yellow} (#{location}) \nFAILED #{total_failures} / #{total_times_run} times" @failures.each { |failure| puts failure.failure_summary } end |