Methods
T
Instance Public methods
test_subscribed()
# File activesupport/test/notifications_test.rb, line 28
def test_subscribed
  name     = "foo"
  name2    = name * 2
  expected = [name, name]

  events   = []
  callback = lambda {|*_| events << _.first}
  ActiveSupport::Notifications.subscribed(callback, name) do
    ActiveSupport::Notifications.instrument(name)
    ActiveSupport::Notifications.instrument(name2)
    ActiveSupport::Notifications.instrument(name)
  end
  assert_equal expected, events

  ActiveSupport::Notifications.instrument(name)
  assert_equal expected, events
end
test_subsribing_to_instrumentation_while_inside_it()
# File activesupport/test/notifications_test.rb, line 46
def test_subsribing_to_instrumentation_while_inside_it
  # the repro requires that there are no evented subscribers for the "foo" event,
  # so we have to duplicate some of the setup code
  old_notifier = ActiveSupport::Notifications.notifier
  ActiveSupport::Notifications.notifier = ActiveSupport::Notifications::Fanout.new

  ActiveSupport::Notifications.subscribe('foo', TestSubscriber.new)

  ActiveSupport::Notifications.instrument('foo') do
    ActiveSupport::Notifications.subscribe('foo') {}
  end
ensure
  ActiveSupport::Notifications.notifier = old_notifier
end