-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test helper:
expect { }.to journal_event_including(...)
(#24)
This introduces a new test helper. It allows you to check for one or more matching event being journaled: ```ruby expect { my_code }.to journal_event_including(name: 'foo') expect { my_code }.to journal_events_including({ name: 'foo', value: 1 }, { name: 'foo', value: 2 }) ``` This will only do exact matches on the specified fields (and will not match one way or the other against unspecified fields). Part of the reason I didn't do exact matching across _all_ fields is that things like ID and git commit are generated on the fly, and I figured that what we really want is a way to concisely specify only the fields under test. It also supports negative assertions (in two forms): ```ruby expect { my_code }.not_to journal_event expect { my_code }.to not_journal_event # supports chaining with `.and` ``` And it supports several chainable modifiers: ```ruby expect { my_code }.to journal_event_including(name: 'foo') .with_schema_name('my_event_schema') .with_partition_key(user.id) .with_stream_name('my_stream_name') .with_enqueue_opts(run_at: future_time) .with_priority(999) ``` All of this can be chained together to test for multiple sets of events with multiple sets of options: ```ruby expect { subject.journal! } .to journal_events_including({ name: 'event1', value: 300 }, { name: 'event2', value: 200 }) .with_schema_name('set_1_schema') .with_partition_key('set_1_partition_key') .with_stream_name('set_1_stream_name') .with_priority(10) .and journal_event_including(name: 'event3', value: 100) .with_schema_name('set_2_schema') .with_partition_key('set_2_partition_key') .with_stream_name('set_2_stream_name') .with_priority(20) .and not_journal_event_including(name: 'other_event') ``` As a bonus, this emits a new `ActiveSupport::Notification` that could be consumed to, say, emit a `StatsD` event, etc. I added a callout in the README.
- Loading branch information
Showing
8 changed files
with
277 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Journaled | ||
VERSION = "4.2.0".freeze | ||
VERSION = "4.3.0".freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.