diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-10-27 21:01:31 -0700 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-10-27 21:04:53 -0700 |
commit | cbcb947b00a7c6992cfe42c6b369e87b4fa4ee23 (patch) | |
tree | 303df6f42810dc11a6dfd545c0740046ea07db6a /activesupport/test | |
parent | 9b67b7ba2f74067235c8bd8f9dc02fb6337eda52 (diff) | |
download | rails-cbcb947b00a7c6992cfe42c6b369e87b4fa4ee23.tar.gz rails-cbcb947b00a7c6992cfe42c6b369e87b4fa4ee23.tar.bz2 rails-cbcb947b00a7c6992cfe42c6b369e87b4fa4ee23.zip |
AS::Notifications.subscribe blocks are now yielded the arguments to pass to AS::Notifications::Event.new
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/notifications_test.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb index 7d2bdf5ccf..b763b740af 100644 --- a/activesupport/test/notifications_test.rb +++ b/activesupport/test/notifications_test.rb @@ -52,7 +52,9 @@ class NotificationsMainTest < Test::Unit::TestCase def setup @events = [] Thread.abort_on_exception = true - ActiveSupport::Notifications.subscribe { |event| @events << event } + ActiveSupport::Notifications.subscribe do |*args| + @events << ActiveSupport::Notifications::Event.new(*args) + end end def teardown @@ -124,7 +126,11 @@ class NotificationsMainTest < Test::Unit::TestCase def test_subscriber_with_pattern @another = [] - ActiveSupport::Notifications.subscribe("cache"){ |event| @another << event } + + ActiveSupport::Notifications.subscribe("cache") do |*args| + @another << ActiveSupport::Notifications::Event.new(*args) + end + ActiveSupport::Notifications.instrument(:cache){ 1 } sleep(0.1) @@ -136,7 +142,9 @@ class NotificationsMainTest < Test::Unit::TestCase def test_subscriber_with_pattern_as_regexp @another = [] - ActiveSupport::Notifications.subscribe(/cache/){ |event| @another << event } + ActiveSupport::Notifications.subscribe(/cache/) do |*args| + @another << ActiveSupport::Notifications::Event.new(*args) + end ActiveSupport::Notifications.instrument(:something){ 0 } ActiveSupport::Notifications.instrument(:cache){ 1 } @@ -150,7 +158,9 @@ class NotificationsMainTest < Test::Unit::TestCase def test_with_several_consumers_and_several_events @another = [] - ActiveSupport::Notifications.subscribe { |event| @another << event } + ActiveSupport::Notifications.subscribe do |*args| + @another << ActiveSupport::Notifications::Event.new(*args) + end 1.upto(100) do |i| ActiveSupport::Notifications.instrument(:value){ i } |