aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-01-06 22:23:29 +0100
committerJosé Valim <jose.valim@gmail.com>2010-01-06 22:24:16 +0100
commit74f6ccea201d778e020f8c758013d90ea8a5c8a1 (patch)
tree22ec5f5abfd89014a2402555200d557cc2fb463c /activesupport/test
parent0c2d933f3636a3c66ab189806725eca36f11655c (diff)
downloadrails-74f6ccea201d778e020f8c758013d90ea8a5c8a1.tar.gz
rails-74f6ccea201d778e020f8c758013d90ea8a5c8a1.tar.bz2
rails-74f6ccea201d778e020f8c758013d90ea8a5c8a1.zip
instrumenter should be accessible from ActiveSupport::Notifications.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/notifications_test.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb
index ef6e6d8d22..62849c3d04 100644
--- a/activesupport/test/notifications_test.rb
+++ b/activesupport/test/notifications_test.rb
@@ -5,7 +5,8 @@ module Notifications
def setup
Thread.abort_on_exception = true
- @notifier = ActiveSupport::Notifications::Notifier.new
+ ActiveSupport::Notifications.notifier = nil
+ @notifier = ActiveSupport::Notifications.notifier
@events = []
@notifier.subscribe { |*args| @events << event(*args) }
end
@@ -82,17 +83,19 @@ module Notifications
end
class InstrumentationTest < TestCase
+ delegate :instrument, :to => ActiveSupport::Notifications
+
def test_instrument_returns_block_result
- assert_equal 2, @notifier.instrument(:awesome) { 1 + 1 }
+ assert_equal 2, instrument(:awesome) { 1 + 1 }
end
def test_instrumenter_exposes_its_id
- assert_equal 20, ActiveSupport::Notifications::Instrumenter.new(@notifier).id.size
+ assert_equal 20, ActiveSupport::Notifications.instrumenter.id.size
end
def test_nested_events_can_be_instrumented
- @notifier.instrument(:awesome, :payload => "notifications") do
- @notifier.instrument(:wot, :payload => "child") do
+ instrument(:awesome, :payload => "notifications") do
+ instrument(:wot, :payload => "child") do
1 + 1
end
@@ -112,7 +115,7 @@ module Notifications
def test_instrument_publishes_when_exception_is_raised
begin
- @notifier.instrument(:awesome, :payload => "notifications") do
+ instrument(:awesome, :payload => "notifications") do
raise "OMG"
end
flunk
@@ -127,7 +130,7 @@ module Notifications
end
def test_event_is_pushed_even_without_block
- @notifier.instrument(:awesome, :payload => "notifications")
+ instrument(:awesome, :payload => "notifications")
drain
assert_equal 1, @events.size