Class: RSpec::Rewind::RSpecAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/rewind/rspec_adapter.rb

Instance Method Summary collapse

Instance Method Details

#clear_exception(example_source) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/rspec/rewind/rspec_adapter.rb', line 6

def clear_exception(example_source)
  if example_source.respond_to?(:clear_exception)
    example_source.clear_exception
  elsif example_source.instance_variable_defined?(:@exception)
    example_source.instance_variable_set(:@exception, nil)
  end
end

#clear_execution_result(example_source) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rspec/rewind/rspec_adapter.rb', line 14

def clear_execution_result(example_source)
  return unless example_source.respond_to?(:execution_result)

  result = example_source.execution_result
  return unless result

  set_if_writer(result, :status, nil)
  set_if_writer(result, :exception, nil)
  set_if_writer(result, :pending_message, nil)
  set_if_writer(result, :run_time, nil)
end

#clear_lets(example_source) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rspec/rewind/rspec_adapter.rb', line 26

def clear_lets(example_source)
  return unless example_source.respond_to?(:example_group_instance)

  group_instance = example_source.example_group_instance
  return unless group_instance

  if group_instance.respond_to?(:clear_lets)
    group_instance.clear_lets
  elsif group_instance.instance_variable_defined?(:@__memoized)
    group_instance.instance_variable_set(:@__memoized, nil)
  end
end