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 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
Constructor Details
#initialize(rspec_result_class) ⇒ RspecResultManager
Returns a new instance of RspecResultManager.
15 16 17 18 |
# File 'lib/flakey_spec_catcher/rspec_result_manager.rb', line 15 def initialize(rspec_result_class) @result_class = rspec_result_class @results = [] end |
Instance Method Details
#add_result(desc, location, message = nil) ⇒ Object
20 21 22 23 |
# File 'lib/flakey_spec_catcher/rspec_result_manager.rb', line 20 def add_result(desc, location, = nil) result = @results.find { |r| r.location == location } result ? result.add_run() : @results.push(@result_class.new(desc, location, )) end |
#empty? ⇒ Boolean
39 40 41 |
# File 'lib/flakey_spec_catcher/rspec_result_manager.rb', line 39 def empty? @results.empty? end |
#failures ⇒ Object
31 32 33 |
# File 'lib/flakey_spec_catcher/rspec_result_manager.rb', line 31 def failures @results.select { |r| r.total_failures.positive? } end |
#print_results ⇒ Object
25 26 27 28 29 |
# File 'lib/flakey_spec_catcher/rspec_result_manager.rb', line 25 def print_results puts "\n********** SUMMARY **********" print_successes_count(successes) failures.each(&:print_results) if failures.any? end |
#successes ⇒ Object
35 36 37 |
# File 'lib/flakey_spec_catcher/rspec_result_manager.rb', line 35 def successes @results.select { |r| r.total_failures.zero? } end |