lib/deimos/test_helpers.rb in deimos-ruby-1.22.3 vs lib/deimos/test_helpers.rb in deimos-ruby-1.22.4
- old
+ new
@@ -131,11 +131,11 @@
str += "\nClosest message received: #{min_hash_diff}" if min_hash_diff
str += "\nDiff: #{diff}" if diff
str + "\nAll Messages received:\n#{message_string}"
end
- RSpec::Matchers.define :have_sent do |msg, key=nil, partition_key=nil|
+ RSpec::Matchers.define :have_sent do |msg, key=nil, partition_key=nil, headers=nil|
message = if msg.respond_to?(:with_indifferent_access)
msg.with_indifferent_access
else
msg
end
@@ -145,10 +145,17 @@
hash_matcher.send(:match,
message&.respond_to?(:to_h) ? message.to_h : message,
m[:payload]&.with_indifferent_access) &&
topic == m[:topic] &&
(key.present? ? key == m[:key] : true) &&
- (partition_key.present? ? partition_key == m[:partition_key] : true)
+ (partition_key.present? ? partition_key == m[:partition_key] : true) &&
+ if headers.present?
+ hash_matcher.send(:match,
+ headers&.with_indifferent_access,
+ m[:headers]&.with_indifferent_access)
+ else
+ true
+ end
end
end
if respond_to?(:failure_message)
failure_message do |topic|