class Tracing::Matchers::HaveSpans
@private
Public Class Methods
new(n)
click to toggle source
# File lib/tracing/matchers/have_spans.rb, line 5 def initialize(n) @expected = n end
Public Instance Methods
description()
click to toggle source
@return [String]
# File lib/tracing/matchers/have_spans.rb, line 32 def description desc = "have " desc << "exactly #{@expected} " if exactly? desc << "spans #{@state}" desc.strip end
failure_message()
click to toggle source
@return [String]
# File lib/tracing/matchers/have_spans.rb, line 40 def failure_message if exactly? message = "expected #{@expected} spans" message << " #{@state}" if @state message << ", got #{@actual}" message else "expected any span #{@state}".strip end end
Also aliased as: failure_message_for_should
failure_message_when_negated()
click to toggle source
@return [String]
# File lib/tracing/matchers/have_spans.rb, line 53 def failure_message_when_negated if exactly? message = "did not expect #{@expected} spans" message << " #{@state}" if @state message << ", got #{@actual}" message else "did not expect spans #{@state}".strip end end
Also aliased as: failure_message_for_should_not
finished()
click to toggle source
# File lib/tracing/matchers/have_spans.rb, line 14 def finished @state = :finished self end
matches?(tracer)
click to toggle source
@return [Boolean]
# File lib/tracing/matchers/have_spans.rb, line 20 def matches?(tracer) @subject = tracer if exactly? @actual = spans.size @actual == @expected else spans.any? end end
started()
click to toggle source
# File lib/tracing/matchers/have_spans.rb, line 9 def started @state = :started self end
Private Instance Methods
exactly?()
click to toggle source
# File lib/tracing/matchers/have_spans.rb, line 75 def exactly? @expected.is_a?(Fixnum) end
spans()
click to toggle source
# File lib/tracing/matchers/have_spans.rb, line 71 def spans state == :finished ? @subject.finished_spans : @subject.spans end
state()
click to toggle source
# File lib/tracing/matchers/have_spans.rb, line 67 def state @state || :started end