Class: RSpec::Rewind::ExampleStateResetter
- Inherits:
-
Object
- Object
- RSpec::Rewind::ExampleStateResetter
- Defined in:
- lib/rspec/rewind/example_state_resetter.rb
Instance Attribute Summary collapse
-
#last_exception ⇒ Object
readonly
Returns the value of attribute last_exception.
Instance Method Summary collapse
-
#initialize(configuration:, adapter: RSpecAdapter.new) ⇒ ExampleStateResetter
constructor
A new instance of ExampleStateResetter.
- #reset(example_source) ⇒ Object
Constructor Details
#initialize(configuration:, adapter: RSpecAdapter.new) ⇒ ExampleStateResetter
Returns a new instance of ExampleStateResetter.
8 9 10 11 12 |
# File 'lib/rspec/rewind/example_state_resetter.rb', line 8 def initialize(configuration:, adapter: RSpecAdapter.new) @configuration = configuration @adapter = adapter @last_exception = nil end |
Instance Attribute Details
#last_exception ⇒ Object (readonly)
Returns the value of attribute last_exception.
6 7 8 |
# File 'lib/rspec/rewind/example_state_resetter.rb', line 6 def last_exception @last_exception end |
Instance Method Details
#reset(example_source) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rspec/rewind/example_state_resetter.rb', line 14 def reset(example_source) @last_exception = nil @adapter.clear_exception(example_source) @adapter.clear_execution_result(example_source) @adapter.clear_lets(example_source) if @configuration.clear_lets_on_failure true rescue StandardError => e @last_exception = e raise if @configuration.reset_failure_policy == :raise false end |