method
assert_notifications_count
v8.1.1 -
Show latest stable
- Class:
ActiveSupport::Testing::NotificationAssertions
assert_notifications_count(pattern, count, &block)public
Assert the number of notifications emitted with a given pattern.
You can assert the number of notifications emitted by passing a pattern, which accepts either a string or regexp, a count, and a block. While the block is executed, the number of matching notifications emitted will be counted. After the block’s execution completes, the assertion will pass if the count matches.
assert_notifications_count("post.submitted", 1) do post.submit(title: "Cool Post") # => emits matching notification end