Class: RSpec::Rewind::RetrySummary
- Inherits:
-
Object
- Object
- RSpec::Rewind::RetrySummary
- Defined in:
- lib/rspec/rewind/retry_summary.rb
Instance Attribute Summary collapse
-
#flaky_examples ⇒ Object
readonly
Returns the value of attribute flaky_examples.
-
#not_retried_events ⇒ Object
readonly
Returns the value of attribute not_retried_events.
-
#reset_failed_events ⇒ Object
readonly
Returns the value of attribute reset_failed_events.
-
#retry_events ⇒ Object
readonly
Returns the value of attribute retry_events.
-
#sleep_seconds ⇒ Object
readonly
Returns the value of attribute sleep_seconds.
Instance Method Summary collapse
-
#initialize ⇒ RetrySummary
constructor
A new instance of RetrySummary.
- #record(event) ⇒ Object
- #reset! ⇒ Object
- #to_message(budget:) ⇒ Object
Constructor Details
#initialize ⇒ RetrySummary
Returns a new instance of RetrySummary.
10 11 12 |
# File 'lib/rspec/rewind/retry_summary.rb', line 10 def initialize reset! end |
Instance Attribute Details
#flaky_examples ⇒ Object (readonly)
Returns the value of attribute flaky_examples.
8 9 10 |
# File 'lib/rspec/rewind/retry_summary.rb', line 8 def flaky_examples @flaky_examples end |
#not_retried_events ⇒ Object (readonly)
Returns the value of attribute not_retried_events.
8 9 10 |
# File 'lib/rspec/rewind/retry_summary.rb', line 8 def not_retried_events @not_retried_events end |
#reset_failed_events ⇒ Object (readonly)
Returns the value of attribute reset_failed_events.
8 9 10 |
# File 'lib/rspec/rewind/retry_summary.rb', line 8 def reset_failed_events @reset_failed_events end |
#retry_events ⇒ Object (readonly)
Returns the value of attribute retry_events.
8 9 10 |
# File 'lib/rspec/rewind/retry_summary.rb', line 8 def retry_events @retry_events end |
#sleep_seconds ⇒ Object (readonly)
Returns the value of attribute sleep_seconds.
8 9 10 |
# File 'lib/rspec/rewind/retry_summary.rb', line 8 def sleep_seconds @sleep_seconds end |
Instance Method Details
#record(event) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rspec/rewind/retry_summary.rb', line 14 def record(event) @mutex.synchronize do case event.status when :retrying @retry_events += 1 @sleep_seconds += event.actual_sleep_seconds.to_f when :flaky @flaky_examples += 1 when :not_retried @not_retried_events += 1 when :reset_failed @reset_failed_events += 1 end end end |
#reset! ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/rspec/rewind/retry_summary.rb', line 30 def reset! @mutex = Mutex.new @retry_events = 0 @flaky_examples = 0 @not_retried_events = 0 @reset_failed_events = 0 @sleep_seconds = 0.0 end |
#to_message(budget:) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rspec/rewind/retry_summary.rb', line 39 def (budget:) parts = [ "#{@flaky_examples} flaky examples", "#{@retry_events} retry attempts", "#{format('%.3f', @sleep_seconds)}s spent sleeping", "#{@not_retried_events} not retried", "#{@reset_failed_events} reset failures" ] parts << (budget) "[rspec-rewind] #{parts.compact.join(', ')}" end |