Class: FlakeySpecCatcher::RspecResultManager
- Inherits:
-
Object
- Object
- FlakeySpecCatcher::RspecResultManager
- Defined in:
- lib/flakey_spec_catcher/rspec_result_manager.rb
Overview
RspecResultManager class
Holds a collection of RSpec results and provides helper methods
An RspecResultManager will hold a collection of results, one for each distinct example. It also provides helpers for adding new results, displaying aggregate results, and checking the state of the collection.
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
- #add_result(desc, location, message = nil) ⇒ Object
- #empty? ⇒ Boolean
- #failures ⇒ Object
-
#initialize(rspec_result_class) ⇒ RspecResultManager
constructor
A new instance of RspecResultManager.
- #print_results ⇒ Object
- #successes ⇒ Object
- #track_spec_start_times(spec_times) ⇒ Object
Constructor Details
#initialize(rspec_result_class) ⇒ RspecResultManager
Returns a new instance of RspecResultManager.
17 18 19 20 21 |
# File 'lib/flakey_spec_catcher/rspec_result_manager.rb', line 17 def initialize(rspec_result_class) @result_class = rspec_result_class @results = [] @spec_start_times = [] end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
15 16 17 |
# File 'lib/flakey_spec_catcher/rspec_result_manager.rb', line 15 def results @results end |
Instance Method Details
#add_result(desc, location, message = nil) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/flakey_spec_catcher/rspec_result_manager.rb', line 27 def add_result(desc, location, = nil) result = @results.find { |r| r.location == location } if result result.add_run() else @results.push(@result_class.new(desc, location, @spec_start_times, )) end end |
#empty? ⇒ Boolean
50 51 52 |
# File 'lib/flakey_spec_catcher/rspec_result_manager.rb', line 50 def empty? @results.empty? end |
#failures ⇒ Object
42 43 44 |
# File 'lib/flakey_spec_catcher/rspec_result_manager.rb', line 42 def failures @results.select { |r| r.total_failures.positive? } end |
#print_results ⇒ Object
36 37 38 39 40 |
# File 'lib/flakey_spec_catcher/rspec_result_manager.rb', line 36 def print_results puts "\n********** SUMMARY **********" print_successes_count(successes) failures.each(&:print_results) if failures.any? end |
#successes ⇒ Object
46 47 48 |
# File 'lib/flakey_spec_catcher/rspec_result_manager.rb', line 46 def successes @results.select { |r| r.total_failures.zero? } end |
#track_spec_start_times(spec_times) ⇒ Object
23 24 25 |
# File 'lib/flakey_spec_catcher/rspec_result_manager.rb', line 23 def track_spec_start_times(spec_times) @spec_start_times = spec_times end |