class Tracing::Matchers::Span::HaveBaggage
@private
Public Class Methods
new(*args)
click to toggle source
# File lib/tracing/matchers/span/have_baggage.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
Public Instance Methods
description()
click to toggle source
@return [String]
# File lib/tracing/matchers/span/have_baggage.rb, line 24 def description desc = "have baggage" desc << " #{@expected}" unless any? desc end
failure_message()
click to toggle source
@return [String]
# File lib/tracing/matchers/span/have_baggage.rb, line 31 def failure_message any? ? "expected any baggage" : "expected #{@expected} baggage, got #{@actual}" end
Also aliased as: failure_message_for_should
failure_message_when_negated()
click to toggle source
@return [String]
# File lib/tracing/matchers/span/have_baggage.rb, line 37 def failure_message_when_negated any? ? "did not expect any baggage" : "did not expect #{@expected} baggage, got #{@actual}" end
Also aliased as: failure_message_for_should_not
matches?(span)
click to toggle source
@return [Boolean]
# File lib/tracing/matchers/span/have_baggage.rb, line 12 def matches?(span) @subject = span @actual = span.context.baggage if any? @actual.any? else @expected.all? { |k, v| @actual.key?(k) && values_match?(v, @actual[k]) } end end
Private Instance Methods
any?()
click to toggle source
# File lib/tracing/matchers/span/have_baggage.rb, line 44 def any? @expected.empty? end
values_match?(expected, actual)
click to toggle source
# File lib/tracing/matchers/span/have_baggage.rb, line 48 def values_match?(expected, actual) expected.is_a?(Regexp) ? expected.match(actual) : expected == actual end