Replies: 3 comments 3 replies
-
This is cool! I think we'd be happy to include this in the gem. We're going to be starting a refactor for Noticed v2 and will have some major changes, so it will likely be best implemented after those improvements are made. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Sounds intriguing 😁 👍🏻 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Any update on how to test notifiers, now that v2.0 is out? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Greetings! Just wanted to put this out there for others that might be looking for it. Less for testing notifications themselves and instead for testing things that fire off notifications, validating that notifications were indeed fired off. This obviously only works for notifications that are delivered by database, such that records would actually exist to verify a notification actually got created... but it gives us a nice RSpec syntax:
Neato.
Not sure whether this (or a variant of it) will become a built-in feature from this library, but it makes my tests feel a little cleaner and more specific — adding a custom matcher to your own app (instead of hoping it gets built into Noticed) is as easy as:
and
This matcher will make sure that at least one notification of the given type was generated for the given recipient. The recipient must have the
has_many :notifications, as: :recipient
relationship already defined on their model.One might quickly draft up a matcher that uses the expectation block format to ensure that only one notification is generated instead of this non-block-format 'at least one exists', but this was enough for me. ✌️
Beta Was this translation helpful? Give feedback.
All reactions