Skip to content

Instantly share code, notes, and snippets.

@stolarczykt
Created April 13, 2022 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stolarczykt/bfdedb46bb57ea10734cdb1d33696b5d to your computer and use it in GitHub Desktop.
Save stolarczykt/bfdedb46bb57ea10734cdb1d33696b5d to your computer and use it in GitHub Desktop.
def assert_events(stream_name, *expected_events)
scope = Rails.configuration.event_store.read.stream(stream_name)
before = scope.last
yield
actual_events = before.nil? ? scope.to_a : scope.from(before.event_id).to_a
to_compare = ->(ev) { { type: ev.event_type, data: ev.data } }
assert_equal expected_events.map(&to_compare),
actual_events.map(&to_compare)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment