Class: Tracing::Matchers::HaveSpan
- Inherits:
-
Object
- Object
- Tracing::Matchers::HaveSpan
- Defined in:
- lib/tracing/matchers/have_span.rb
Instance Method Summary collapse
- #child_of(parent = :any) ⇒ Object (also: #with_parent)
- #description ⇒ String
- #failure_message ⇒ String (also: #failure_message_for_should)
- #failure_message_when_negated ⇒ String (also: #failure_message_for_should_not)
- #finished ⇒ Object
- #follow_after(previous) ⇒ Object (also: #following_after)
- #in_progress ⇒ Object (also: #started)
-
#initialize(operation_name) ⇒ HaveSpan
constructor
A new instance of HaveSpan.
- #matches?(tracer) ⇒ Boolean
- #with_baggage(*args) ⇒ Object
- #with_log(**fields) ⇒ Object (also: #with_logs)
- #with_tag(*args) ⇒ Object (also: #with_tags)
Constructor Details
#initialize(operation_name) ⇒ HaveSpan
Returns a new instance of HaveSpan.
5 6 7 8 |
# File 'lib/tracing/matchers/have_span.rb', line 5 def initialize(operation_name) @expected = operation_name @predicates = [] end |
Instance Method Details
#child_of(parent = :any) ⇒ Object Also known as: with_parent
38 39 40 41 |
# File 'lib/tracing/matchers/have_span.rb', line 38 def child_of(parent = :any) @predicates << Tracing::Matchers::Span::BeChildOf.new(parent) self end |
#description ⇒ String
59 60 61 |
# File 'lib/tracing/matchers/have_span.rb', line 59 def description "have a#{expected_span_description}" end |
#failure_message ⇒ String Also known as: failure_message_for_should
64 65 66 |
# File 'lib/tracing/matchers/have_span.rb', line 64 def "expected a#{expected_span_description}, suggestions \n#{suggestions.map(&:to_s).join("\n")}" end |
#failure_message_when_negated ⇒ String Also known as: failure_message_for_should_not
70 71 72 |
# File 'lib/tracing/matchers/have_span.rb', line 70 def "did not expect#{expected_span_description}" end |
#finished ⇒ Object
16 17 18 19 |
# File 'lib/tracing/matchers/have_span.rb', line 16 def finished @state_predicate = RSpec::Matchers::BuiltIn::BePredicate.new(:be_finished) self end |
#follow_after(previous) ⇒ Object Also known as: following_after
44 45 46 47 |
# File 'lib/tracing/matchers/have_span.rb', line 44 def follow_after(previous) @predicates << Tracing::Matchers::Span::FollowAfter.new(previous) self end |
#in_progress ⇒ Object Also known as: started
10 11 12 13 |
# File 'lib/tracing/matchers/have_span.rb', line 10 def in_progress @state_predicate = RSpec::Matchers::BuiltIn::BePredicate.new(:be_started) self end |
#matches?(tracer) ⇒ Boolean
51 52 53 54 55 56 |
# File 'lib/tracing/matchers/have_span.rb', line 51 def matches?(tracer) @subject = tracer @actual = actual_spans @actual.any? { |span| all_predicates.all? { |matcher| matcher.matches?(span) } } end |
#with_baggage(*args) ⇒ Object
33 34 35 36 |
# File 'lib/tracing/matchers/have_span.rb', line 33 def with_baggage(*args) @predicates << Tracing::Matchers::Span::HaveBaggage.new(*args) self end |