method

assert_notifications_count

rails latest stable - Class: ActiveSupport::Testing::NotificationAssertions

Method not available on this version

This method is only available on newer versions. The first available version (v8.1.1) is shown here.

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