instance method
capture_notifications
Ruby on Rails 8.1.2
Since v8.1.2Signature
capture_notifications(pattern = nil, &block)
Capture emitted notifications, optionally filtered by a pattern.
You can capture emitted notifications, optionally filtered by a pattern, which accepts either a string or regexp, and a block.
notifications = capture_notifications("post.submitted") do post.submit(title: "Cool Post") # => emits matching notification end
Parameters
-
patternopt = nil -
blockblock
Source
# File activesupport/lib/active_support/testing/notification_assertions.rb, line 85
def capture_notifications(pattern = nil, &block)
notifications = []
ActiveSupport::Notifications.subscribed(->(n) { notifications << n }, pattern, &block)
notifications
end
Defined in activesupport/lib/active_support/testing/notification_assertions.rb line 85
· View on GitHub
· Improve this page
· Find usages on GitHub