Class: RSpec::Rewind::AttemptRunner
- Inherits:
-
Object
- Object
- RSpec::Rewind::AttemptRunner
- Defined in:
- lib/rspec/rewind/attempt_runner.rb
Constant Summary collapse
- FATAL_EXCEPTIONS =
[ NoMemoryError, ScriptError, SignalException, SystemExit, SecurityError ].freeze
Instance Method Summary collapse
-
#initialize(clock: nil) ⇒ AttemptRunner
constructor
A new instance of AttemptRunner.
- #run(run_target:, exception_source:) ⇒ Object
Constructor Details
#initialize(clock: nil) ⇒ AttemptRunner
Returns a new instance of AttemptRunner.
14 15 16 |
# File 'lib/rspec/rewind/attempt_runner.rb', line 14 def initialize(clock: nil) @clock = clock || -> { Process.clock_gettime(Process::CLOCK_MONOTONIC) } end |
Instance Method Details
#run(run_target:, exception_source:) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rspec/rewind/attempt_runner.rb', line 18 def run(run_target:, exception_source:) started_at = monotonic_time begin run_target.run duration = monotonic_time - started_at [current_exception(exception_source), duration, false] # RSpec expectation failures inherit from Exception, so fatal exceptions are filtered explicitly. rescue Exception => e # rubocop:disable Lint/RescueException raise if fatal_exception?(e) duration = monotonic_time - started_at [e, duration, true] end end |