Class: Tracing::Matchers::HaveSpan

Inherits:
Object
  • Object
show all
Defined in:
lib/tracing/matchers/have_span.rb

Instance Method Summary collapse

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

Returns:

  • (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

Returns:

  • (String)


64
65
66
# File 'lib/tracing/matchers/have_span.rb', line 64

def failure_message
  "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

Returns:

  • (String)


70
71
72
# File 'lib/tracing/matchers/have_span.rb', line 70

def failure_message_when_negated
  "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

Returns:

  • (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

#with_log(**fields) ⇒ Object Also known as: with_logs



27
28
29
30
# File 'lib/tracing/matchers/have_span.rb', line 27

def with_log(**fields)
  @predicates << Tracing::Matchers::Span::HaveLog.new(**fields)
  self
end

#with_tag(*args) ⇒ Object Also known as: with_tags



21
22
23
24
# File 'lib/tracing/matchers/have_span.rb', line 21

def with_tag(*args)
  @predicates << Tracing::Matchers::Span::HaveTag.new(*args)
  self
end