Class: RSpec::Covers::Probe::CallLog
- Inherits:
-
Object
- Object
- RSpec::Covers::Probe::CallLog
- Defined in:
- lib/rspec/covers/probe/call_log_probe.rb
Instance Attribute Summary collapse
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
-
#expectations ⇒ Object
readonly
Returns the value of attribute expectations.
-
#returns_by_object_id ⇒ Object
readonly
Returns the value of attribute returns_by_object_id.
Instance Method Summary collapse
- #calls_before_expectations ⇒ Object
- #expectation_object_ids ⇒ Object
-
#initialize(calls:, returns_by_object_id:, expectations: []) ⇒ CallLog
constructor
A new instance of CallLog.
- #labels ⇒ Object
- #labels_before_expectations ⇒ Object
- #last_call ⇒ Object
- #return_labels_for(object_ids) ⇒ Object
Constructor Details
#initialize(calls:, returns_by_object_id:, expectations: []) ⇒ CallLog
Returns a new instance of CallLog.
25 26 27 28 29 |
# File 'lib/rspec/covers/probe/call_log_probe.rb', line 25 def initialize(calls:, returns_by_object_id:, expectations: []) @calls = calls @returns_by_object_id = returns_by_object_id @expectations = expectations end |
Instance Attribute Details
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
23 24 25 |
# File 'lib/rspec/covers/probe/call_log_probe.rb', line 23 def calls @calls end |
#expectations ⇒ Object (readonly)
Returns the value of attribute expectations.
23 24 25 |
# File 'lib/rspec/covers/probe/call_log_probe.rb', line 23 def expectations @expectations end |
#returns_by_object_id ⇒ Object (readonly)
Returns the value of attribute returns_by_object_id.
23 24 25 |
# File 'lib/rspec/covers/probe/call_log_probe.rb', line 23 def returns_by_object_id @returns_by_object_id end |
Instance Method Details
#calls_before_expectations ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/rspec/covers/probe/call_log_probe.rb', line 35 def calls_before_expectations expectations.filter_map do |expectation| next if expectation.call_index.to_i <= 0 calls[expectation.call_index - 1] end end |
#expectation_object_ids ⇒ Object
51 52 53 |
# File 'lib/rspec/covers/probe/call_log_probe.rb', line 51 def expectation_object_ids expectations.map(&:actual_object_id) end |
#labels ⇒ Object
47 48 49 |
# File 'lib/rspec/covers/probe/call_log_probe.rb', line 47 def labels calls.map(&:label) end |
#labels_before_expectations ⇒ Object
43 44 45 |
# File 'lib/rspec/covers/probe/call_log_probe.rb', line 43 def labels_before_expectations calls_before_expectations.map(&:label).uniq end |
#last_call ⇒ Object
31 32 33 |
# File 'lib/rspec/covers/probe/call_log_probe.rb', line 31 def last_call calls.last end |
#return_labels_for(object_ids) ⇒ Object
55 56 57 |
# File 'lib/rspec/covers/probe/call_log_probe.rb', line 55 def return_labels_for(object_ids) object_ids.flat_map { |object_id| returns_by_object_id.fetch(object_id, []) }.uniq end |