diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-11-28 12:49:07 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-11-28 12:50:09 -0800 |
commit | 4f2a04cc085b9117e8af8079a95a063f671d7a3d (patch) | |
tree | fd96c9bc52dc13d3338ed08f4afcd1c685dc6348 /railties | |
parent | 02893d17053123cbf02b65c2fe549421c11a2604 (diff) | |
download | rails-4f2a04cc085b9117e8af8079a95a063f671d7a3d.tar.gz rails-4f2a04cc085b9117e8af8079a95a063f671d7a3d.tar.bz2 rails-4f2a04cc085b9117e8af8079a95a063f671d7a3d.zip |
Notifications: extract central Notifier, cordon off the internal Fanout implementation, and segregate instrumentation concerns
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/application/notifications_test.rb | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/railties/test/application/notifications_test.rb b/railties/test/application/notifications_test.rb index 28dfdfcd83..71e406f2c1 100644 --- a/railties/test/application/notifications_test.rb +++ b/railties/test/application/notifications_test.rb @@ -5,21 +5,8 @@ module ApplicationTests include ActiveSupport::Testing::Isolation class MyQueue - attr_reader :events, :subscribers - - def initialize - @events = [] - @subscribers = [] - @listeners = [] - end - def publish(name, *args) - @events << name - end - - def subscribe(listener, pattern=nil, &block) - @listeners << listener - @subscribers << pattern + raise name end end @@ -28,21 +15,16 @@ module ApplicationTests boot_rails require "rails" require "active_support/notifications" + @events = [] Rails::Initializer.run do |c| - c.notifications.queue = MyQueue.new - c.notifications.subscribe(/listening/) do - puts "Cool" - end + c.notifications.notifier = ActiveSupport::Notifications::Notifier.new(MyQueue.new) end end test "new queue is set" do - ActiveSupport::Notifications.instrument(:foo) - assert_equal :foo, ActiveSupport::Notifications.queue.events.first - end - - test "configuration subscribers are loaded" do - assert_equal 1, ActiveSupport::Notifications.queue.subscribers.count { |s| s == /listening/ } + assert_raise RuntimeError do + ActiveSupport::Notifications.publish('foo') + end end end end |