Class: BrainzLab::Testing::TraceExpectation
- Inherits:
-
Object
- Object
- BrainzLab::Testing::TraceExpectation
- Defined in:
- lib/brainzlab/testing/helpers.rb
Overview
Fluent expectation builder for traces
Instance Method Summary collapse
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(name, store) ⇒ TraceExpectation
constructor
A new instance of TraceExpectation.
-
#satisfied? ⇒ Boolean
(also: #matches?)
Check if the expectation is satisfied.
-
#with(opts) ⇒ self
Specify expected options.
Constructor Details
#initialize(name, store) ⇒ TraceExpectation
Returns a new instance of TraceExpectation.
560 561 562 563 564 |
# File 'lib/brainzlab/testing/helpers.rb', line 560 def initialize(name, store) @name = name.to_s @store = store @expected_opts = nil end |
Instance Method Details
#failure_message ⇒ Object
586 587 588 589 590 591 |
# File 'lib/brainzlab/testing/helpers.rb', line 586 def parts = ["expected trace '#{@name}'"] parts << "with options #{@expected_opts.inspect}" if @expected_opts parts << " to be recorded, but it wasn't" parts.join end |
#failure_message_when_negated ⇒ Object
593 594 595 |
# File 'lib/brainzlab/testing/helpers.rb', line 593 def "expected trace '#{@name}' not to be recorded, but it was" end |
#satisfied? ⇒ Boolean Also known as: matches?
Check if the expectation is satisfied
580 581 582 |
# File 'lib/brainzlab/testing/helpers.rb', line 580 def satisfied? @store.trace_recorded?(@name, @expected_opts) end |
#with(opts) ⇒ self
Specify expected options
571 572 573 574 |
# File 'lib/brainzlab/testing/helpers.rb', line 571 def with(opts) @expected_opts = opts self end |