Class: Tracing::Matchers::Span::HaveTag
- Inherits:
-
Object
- Object
- Tracing::Matchers::Span::HaveTag
- Defined in:
- lib/tracing/matchers/span/have_tag.rb
Instance Method Summary collapse
- #description ⇒ String
- #failure_message ⇒ String (also: #failure_message_for_should)
- #failure_message_when_negated ⇒ String (also: #failure_message_for_should_not)
-
#initialize(*args) ⇒ HaveTag
constructor
A new instance of HaveTag.
- #matches?(span) ⇒ Boolean
Constructor Details
#initialize(*args) ⇒ HaveTag
Returns a new instance of HaveTag.
6 7 8 9 |
# File 'lib/tracing/matchers/span/have_tag.rb', line 6 def initialize(*args) @expected = args.last.is_a?(Hash) ? args.delete_at(-1) : Hash.new args.each_slice(2) { |k, v| @expected[k] = v } end |
Instance Method Details
#description ⇒ String
24 25 26 27 28 |
# File 'lib/tracing/matchers/span/have_tag.rb', line 24 def description desc = "have tags" desc << " #{@expected}" unless any? desc end |
#failure_message ⇒ String Also known as: failure_message_for_should
31 32 33 |
# File 'lib/tracing/matchers/span/have_tag.rb', line 31 def any? ? "expected any tag" : "expected #{@expected} tags, got #{@actual}" end |
#failure_message_when_negated ⇒ String Also known as: failure_message_for_should_not
37 38 39 |
# File 'lib/tracing/matchers/span/have_tag.rb', line 37 def any? ? "did not expect any tag" : "did not expect #{@expected} tags, got #{@actual}" end |
#matches?(span) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tracing/matchers/span/have_tag.rb', line 12 def matches?(span) @subject = span @actual = span. if any? @actual.any? else @expected.all? { |k, v| @actual.key?(k) && values_match?(v, @actual[k]) } end end |