Class: BrainzLab::Testing::Matchers::HaveBeenTracedMatcher
- Inherits:
-
Object
- Object
- BrainzLab::Testing::Matchers::HaveBeenTracedMatcher
- Defined in:
- lib/brainzlab/testing/matchers.rb
Overview
Matcher for traces
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize ⇒ HaveBeenTracedMatcher
constructor
A new instance of HaveBeenTracedMatcher.
- #matches?(trace_name) ⇒ Boolean
- #with(opts) ⇒ Object
Constructor Details
#initialize ⇒ HaveBeenTracedMatcher
Returns a new instance of HaveBeenTracedMatcher.
295 296 297 |
# File 'lib/brainzlab/testing/matchers.rb', line 295 def initialize @expected_opts = nil end |
Instance Method Details
#description ⇒ Object
325 326 327 328 329 |
# File 'lib/brainzlab/testing/matchers.rb', line 325 def description desc = "have traced '#{@trace_name}'" desc += " with #{@expected_opts.inspect}" if @expected_opts desc end |
#failure_message ⇒ Object
309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/brainzlab/testing/matchers.rb', line 309 def actual_traces = BrainzLab::Testing.event_store.traces if actual_traces.empty? "expected trace '#{@trace_name}' to have been recorded, but no traces were found" else msg = "expected trace '#{@trace_name}'" msg += " with options #{@expected_opts.inspect}" if @expected_opts msg + ", but recorded traces were:\n #{actual_traces.map { |t| t[:name] }.inspect}" end end |
#failure_message_when_negated ⇒ Object
321 322 323 |
# File 'lib/brainzlab/testing/matchers.rb', line 321 def "expected trace '#{@trace_name}' not to have been recorded, but it was" end |
#matches?(trace_name) ⇒ Boolean
304 305 306 307 |
# File 'lib/brainzlab/testing/matchers.rb', line 304 def matches?(trace_name) @trace_name = trace_name.to_s BrainzLab::Testing.event_store.trace_recorded?(@trace_name, @expected_opts) end |
#with(opts) ⇒ Object
299 300 301 302 |
# File 'lib/brainzlab/testing/matchers.rb', line 299 def with(opts) @expected_opts = opts self end |