Class: Tracing::Matchers::Span::HaveLog
- Inherits:
-
Object
- Object
- Tracing::Matchers::Span::HaveLog
- Defined in:
- lib/tracing/matchers/span/have_log.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(**fields) ⇒ HaveLog
constructor
A new instance of HaveLog.
- #matches?(span) ⇒ Boolean
Constructor Details
#initialize(**fields) ⇒ HaveLog
Returns a new instance of HaveLog.
6 7 8 |
# File 'lib/tracing/matchers/span/have_log.rb', line 6 def initialize(**fields) @expected = fields end |
Instance Method Details
#description ⇒ String
25 26 27 28 29 |
# File 'lib/tracing/matchers/span/have_log.rb', line 25 def description desc = "have log entry" desc << " #{@expected}" unless any? desc end |
#failure_message ⇒ String Also known as: failure_message_for_should
32 33 34 |
# File 'lib/tracing/matchers/span/have_log.rb', line 32 def any? ? "expected any log entry" : "expected #{@expected} log entry, got #{@actual}" end |
#failure_message_when_negated ⇒ String Also known as: failure_message_for_should_not
38 39 40 |
# File 'lib/tracing/matchers/span/have_log.rb', line 38 def any? ? "did not expect any log entry" : "did not expect #{@expected} log entry, got #{@actual}" end |
#matches?(span) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/tracing/matchers/span/have_log.rb', line 11 def matches?(span) @subject = span @actual = span.logs.map { |log| log.fields.dup.tap { |h| h[:event] = log.event } } if any? @actual.any? else @actual.any? do |log| @expected.all? { |k, v| log.key?(k) && values_match?(v, log[k]) } end end end |