Methods
T
Instance Public methods
test_subscribe_events()
   # File activesupport/test/notifications_test.rb
30 def test_subscribe_events
31   events = []
32   @notifier.subscribe do |event|
33     events << event
34   end
35 
36   ActiveSupport::Notifications.instrument("foo")
37   event = events.first
38   assert event, "should have an event"
39   assert_operator event.allocations, :>, 0
40   assert_operator event.cpu_time, :>, 0
41   assert_operator event.idle_time, :>, 0
42   assert_operator event.duration, :>, 0
43 end
test_subscribe_via_top_level_api()
   # File activesupport/test/notifications_test.rb
45 def test_subscribe_via_top_level_api
46   old_notifier = ActiveSupport::Notifications.notifier
47   ActiveSupport::Notifications.notifier = ActiveSupport::Notifications::Fanout.new
48 
49   event = nil
50   ActiveSupport::Notifications.subscribe("foo") do |e|
51     event = e
52   end
53 
54   ActiveSupport::Notifications.instrument("foo") do
55     100.times { Object.new } # allocate at least 100 objects
56   end
57 
58   assert event
59   assert_operator event.allocations, :>=, 100
60 ensure
61   ActiveSupport::Notifications.notifier = old_notifier
62 end