Replies: 2 comments
-
|
Am I missing anything obvious here? Or am I ok to start working on a PR? |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Ended up adding this to def assert_notifies_with(klass, &block)
arg_matcher = -> (args) { args[0].is_a?(klass) }
assert_enqueued_with(job: Noticed::EventJob, args: arg_matcher, &block)
end
# Usage:
assert_notifies_with OwnershipNotifier do
Ownership.transfer(...) # Something that should create a OwnershipNotifier::Notification
end |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When I write tests that check if a notification is being sent, I can easily check whether the code enqueues a
Noticed::EventJob. But it's not easy to check which notification the code enqueues.This recently became a problem because I had one method that enqueued the wrong notification and my tests didn't catch it.
I think it would be a good idea to add a simpler helper similar to
ActiveJob::TestHelperwhich allows for testing the notification being sent.Happy to spend some time here if needed!
Beta Was this translation helpful? Give feedback.
All reactions