diff options
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/orchestra_test.rb | 49 |
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 |