diff --git a/test/notifications_test.rb b/test/notifications_test.rb new file mode 100644 index 0000000..8052c40 --- /dev/null +++ b/test/notifications_test.rb @@ -0,0 +1,25 @@ +require_relative "test_helper" + +class NotificationsTest < Minitest::Test + def test_search + notifications = capture_notifications do + Product.search("product").to_a + end + + assert_equal 1, notifications.size + assert_equal "search.searchkick", notifications.last[:name] + end + + private + + def capture_notifications + notifications = [] + callback = lambda do |name, started, finished, unique_id, payload| + notifications << {name: name, payload: payload} + end + ActiveSupport::Notifications.subscribed(callback, /searchkick/) do + yield + end + notifications + end +end -- libgit2 0.21.0