Class: RSpec::Rewind::RetryNotifier
- Inherits:
-
Object
- Object
- RSpec::Rewind::RetryNotifier
- Defined in:
- lib/rspec/rewind/retry_notifier.rb
Instance Method Summary collapse
-
#initialize(configuration:, debug:, reporter_message:) ⇒ RetryNotifier
constructor
A new instance of RetryNotifier.
- #notify_after_retry(event) ⇒ Object
- #notify_before_retry(event) ⇒ Object
- #notify_retry(event) ⇒ Object
- #publish_flaky(event) ⇒ Object
- #publish_not_retried(event) ⇒ Object
- #publish_reset_failed(event) ⇒ Object
- #show_failure_message(exception) ⇒ Object
Constructor Details
#initialize(configuration:, debug:, reporter_message:) ⇒ RetryNotifier
Returns a new instance of RetryNotifier.
6 7 8 9 10 |
# File 'lib/rspec/rewind/retry_notifier.rb', line 6 def initialize(configuration:, debug:, reporter_message:) @configuration = configuration @debug = debug @reporter_message = end |
Instance Method Details
#notify_after_retry(event) ⇒ Object
23 24 25 |
# File 'lib/rspec/rewind/retry_notifier.rb', line 23 def notify_after_retry(event) invoke_callback(@configuration.after_retry, event, 'after_retry hook') end |
#notify_before_retry(event) ⇒ Object
19 20 21 |
# File 'lib/rspec/rewind/retry_notifier.rb', line 19 def notify_before_retry(event) invoke_callback(@configuration.before_retry, event, 'before_retry hook') end |
#notify_retry(event) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/rspec/rewind/retry_notifier.rb', line 12 def notify_retry(event) debug("retry #{event.attempt}/#{event.retries} for #{event.example_id} in #{event.sleep_seconds.round(3)}s") record_summary(event) publish_retry_report(event) if @configuration.report_retry_events invoke_callback(@configuration.retry_callback, event, 'retry callback') end |
#publish_flaky(event) ⇒ Object
40 41 42 43 44 |
# File 'lib/rspec/rewind/retry_notifier.rb', line 40 def publish_flaky(event) record_summary(event) publish_flaky_report(event) invoke_callback(@configuration.flaky_callback, event, 'flaky callback') end |
#publish_not_retried(event) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/rspec/rewind/retry_notifier.rb', line 27 def publish_not_retried(event) debug("not retrying #{event.example_id}: #{event.decision_reason}") record_summary(event) publish_retry_report(event) if @configuration.report_retry_events invoke_callback(@configuration.not_retried_callback, event, 'not_retried callback') end |
#publish_reset_failed(event) ⇒ Object
34 35 36 37 38 |
# File 'lib/rspec/rewind/retry_notifier.rb', line 34 def publish_reset_failed(event) debug("state reset failed for #{event.example_id}: #{event.exception_class}: #{event.}") record_summary(event) publish_retry_report(event) if @configuration.report_retry_events end |
#show_failure_message(exception) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/rspec/rewind/retry_notifier.rb', line 46 def (exception) = "[rspec-rewind] #{exception.class}: #{exception.}" if @configuration.display_retry_backtrace_top && exception.backtrace&.first = "#{} (#{exception.backtrace.first})" end @reporter_message.call() end |