Class: RSpec::Covers::Probe::CallLogProbe
- Inherits:
-
Object
- Object
- RSpec::Covers::Probe::CallLogProbe
- Defined in:
- lib/rspec/covers/probe/call_log_probe.rb
Instance Method Summary collapse
- #active? ⇒ Boolean
-
#initialize(config) ⇒ CallLogProbe
constructor
A new instance of CallLogProbe.
- #record_expectation(actual) ⇒ Object
- #start_example ⇒ Object
- #stop_example ⇒ Object
Constructor Details
#initialize(config) ⇒ CallLogProbe
Returns a new instance of CallLogProbe.
61 62 63 |
# File 'lib/rspec/covers/probe/call_log_probe.rb', line 61 def initialize(config) @config = config end |
Instance Method Details
#active? ⇒ Boolean
74 75 76 |
# File 'lib/rspec/covers/probe/call_log_probe.rb', line 74 def active? !@trace_point.nil? end |
#record_expectation(actual) ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/rspec/covers/probe/call_log_probe.rb', line 78 def record_expectation(actual) return unless active? @expectations << Expectation.new( actual_object_id: actual.__id__, call_index: @calls.length ) end |
#start_example ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/rspec/covers/probe/call_log_probe.rb', line 65 def start_example @calls = [] @call_stack = [] @expectations = [] @returns_by_object_id = Hash.new { |hash, key| hash[key] = Set.new } @trace_point = TracePoint.new(:call, :return) { |trace_point| record(trace_point) } @trace_point.enable end |
#stop_example ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/rspec/covers/probe/call_log_probe.rb', line 87 def stop_example @trace_point&.disable CallLog.new( calls: @calls || [], returns_by_object_id: @returns_by_object_id || {}, expectations: @expectations || [] ) ensure @trace_point = nil @calls = nil @call_stack = nil @expectations = nil @returns_by_object_id = nil end |