instance method
assert_no_notifications
Ruby on Rails 8.1.2
Since v8.1.2Signature
assert_no_notifications(pattern = nil, &block)
Assert no notifications were emitted for a given pattern.
You can assert no notifications were emitted by passing a pattern, which accepts either a string or regexp, and a block. While the block is executed, if no matching notifications are emitted, the assertion will pass.
assert_no_notifications("post.submitted") do post.destroy # => emits non-matching notification end
Parameters
-
patternopt = nil -
blockblock
Source
# File activesupport/lib/active_support/testing/notification_assertions.rb, line 66
def assert_no_notifications(pattern = nil, &block)
notifications = capture_notifications(pattern, &block)
error_message = if pattern
"Expected no notifications for #{pattern} but found #{notifications.size}"
else
"Expected no notifications but found #{notifications.size}"
end
assert_empty(notifications, error_message)
end
Defined in activesupport/lib/active_support/testing/notification_assertions.rb line 66
· View on GitHub
· Improve this page
· Find usages on GitHub