JetThoughts Dev
Posted on May 13, 2024
Previously, developers encountered a significant challenge verifying if streams ceased operation correctly. This issue often led to the creation of intricate workarounds or the omission of proper testing.
The Old Way
Here's an example:
assert_not ActionCable.server.pubsub.redis_connection_for_subscriptions.subscribed_to?("messages")
This code works but isn't straightforward to update.
The New Solution
The following Ruby on Rails introduces assert_has_no_stream
and assert_has_no_stream_for
. These new methods simplify the testing of stopped streams.
assert_has_no_stream "messages"
assert_has_no_stream_for User.find(42)
With these new assertion methods, you can straightforwardly express your test goals. This simplicity and clarity strengthen your tests and make them easier to maintain, giving you confidence in the reliability of your code.
💖 💪 🙅 🚩
JetThoughts Dev
Posted on May 13, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.