aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/orchestra_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/orchestra_test.rb')
-rw-r--r--activesupport/test/orchestra_test.rb27
1 files changed, 24 insertions, 3 deletions
diff --git a/activesupport/test/orchestra_test.rb b/activesupport/test/orchestra_test.rb
index 810d99ebeb..7a6e9208b4 100644
--- a/activesupport/test/orchestra_test.rb
+++ b/activesupport/test/orchestra_test.rb
@@ -90,18 +90,39 @@ class OrchestraMainTest < Test::Unit::TestCase
assert_equal Hash[:payload => "orchestra"], @events.last.payload
end
+ def test_event_is_pushed_even_without_block
+ ActiveSupport::Orchestra.instrument(:awesome, :payload => "orchestra")
+ sleep(0.1)
+
+ assert_equal 1, @events.size
+ assert_equal :awesome, @events.last.name
+ assert_equal Hash[:payload => "orchestra"], @events.last.payload
+ end
+
def test_subscriber_with_pattern
@another = []
- ActiveSupport::Orchestra.subscribe(/cache/) { |event| @another << event }
+ ActiveSupport::Orchestra.subscribe("cache"){ |event| @another << event }
+ ActiveSupport::Orchestra.instrument(:cache){ 1 }
+
+ sleep(0.1)
+
+ assert_equal 1, @another.size
+ assert_equal :cache, @another.first.name
+ assert_equal 1, @another.first.result
+ end
+
+ def test_subscriber_with_pattern_as_regexp
+ @another = []
+ ActiveSupport::Orchestra.subscribe(/cache/){ |event| @another << event }
ActiveSupport::Orchestra.instrument(:something){ 0 }
- ActiveSupport::Orchestra.instrument(:cache){ 10 }
+ ActiveSupport::Orchestra.instrument(:cache){ 1 }
sleep(0.1)
assert_equal 1, @another.size
assert_equal :cache, @another.first.name
- assert_equal 10, @another.first.result
+ assert_equal 1, @another.first.result
end
def test_with_several_consumers_and_several_events