spec/models/concerns/subscribable_spec.rb in reactor-0.11.0 vs spec/models/concerns/subscribable_spec.rb in reactor-0.11.1
- old
+ new
@@ -22,10 +22,21 @@
def self.ring_bell(event)
"ring ring! #{event}"
end
end
+module MyNamespace
+ class MyClass
+ include Reactor::Subscribable
+ on_event :rain, :umbrella
+ end
+
+ def self.umbrella
+ puts 'get an umbrella'
+ end
+end
+
Reactor.in_test_mode do
class TestModeAuction < ActiveRecord::Base
on_event :test_puppy_delivered, -> (event) { "success" }
end
end
@@ -42,9 +53,13 @@
describe 'building uniquely named subscriber handler classes' do
it 'adds a static subscriber to the global lookup constant' do
expect(Reactor::SUBSCRIBERS['puppy_delivered'][0]).to eq(Reactor::StaticSubscribers::Auction::PuppyDeliveredHandler)
expect(Reactor::SUBSCRIBERS['puppy_delivered'][1]).to eq(Reactor::StaticSubscribers::Auction::DoNothingHandler)
+ end
+
+ it 'adds a static subscriber for namespaced classes' do
+ expect(Reactor::SUBSCRIBERS['rain'][0]).to eq(Reactor::StaticSubscribers::MyClass::RainHandler)
end
end
describe 'binding symbol of class method' do
it 'fires on event' do