aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-10-09 09:17:08 -0300
committerJosé Valim <jose.valim@gmail.com>2009-10-15 18:19:25 -0300
commitaeaabc6d2d6f9faaa98057f33c0635d8add54461 (patch)
treee4779db2dc0853fae9415b9a2345e568598409f4 /railties/test
parent8f59d7a8d8e736d7f4b6730020c197d008fb0779 (diff)
downloadrails-aeaabc6d2d6f9faaa98057f33c0635d8add54461.tar.gz
rails-aeaabc6d2d6f9faaa98057f33c0635d8add54461.tar.bz2
rails-aeaabc6d2d6f9faaa98057f33c0635d8add54461.zip
Configure Orchestra on initialization.
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/orchestra_test.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/railties/test/application/orchestra_test.rb b/railties/test/application/orchestra_test.rb
new file mode 100644
index 0000000000..38a06be741
--- /dev/null
+++ b/railties/test/application/orchestra_test.rb
@@ -0,0 +1,49 @@
+require "isolation/abstract_unit"
+require "active_support/orchestra"
+
+module ApplicationTests
+ class OrchestraTest < Test::Unit::TestCase
+
+ class MyQueue
+ attr_reader :events, :subscribers
+
+ def initialize
+ @events = []
+ @subscribers = []
+ end
+
+ def publish(name, payload=nil)
+ @events << name
+ end
+
+ def subscribe(pattern=nil, &block)
+ @subscribers << pattern
+ end
+ end
+
+ def setup
+ build_app
+ boot_rails
+
+ Rails::Initializer.run do |c|
+ c.orchestra.queue = MyQueue.new
+ c.orchestra.subscribe(/listening/) do
+ puts "Cool"
+ end
+ end
+ end
+
+ test "new queue is set" do
+ ActiveSupport::Orchestra.instrument(:foo)
+ assert_equal :foo, ActiveSupport::Orchestra.queue.events.first
+ end
+
+ test "frameworks subscribers are loaded" do
+ assert_equal 1, ActiveSupport::Orchestra.queue.subscribers.count { |s| s == "sql" }
+ end
+
+ test "configuration subscribers are loaded" do
+ assert_equal 1, ActiveSupport::Orchestra.queue.subscribers.count { |s| s == /listening/ }
+ end
+ end
+end