diff options
Diffstat (limited to 'spec/support/matchers/event_store.rb')
-rw-r--r-- | spec/support/matchers/event_store.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/spec/support/matchers/event_store.rb b/spec/support/matchers/event_store.rb index eb5b37f39e5..14f6a42d7f4 100644 --- a/spec/support/matchers/event_store.rb +++ b/spec/support/matchers/event_store.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true RSpec::Matchers.define :publish_event do |expected_event_class| + include RSpec::Matchers::Composable + supports_block_expectations match do |proc| @@ -15,10 +17,17 @@ RSpec::Matchers.define :publish_event do |expected_event_class| proc.call @events.any? do |event| - event.instance_of?(expected_event_class) && event.data == @expected_data + event.instance_of?(expected_event_class) && match_data?(event.data, @expected_data) end end + def match_data?(actual, expected) + values_match?(actual.keys, expected.keys) && + actual.keys.each do |key| + values_match?(actual[key], expected[key]) + end + end + chain :with do |expected_data| @expected_data = expected_data end |