spec/models/concerns/subscribable_spec.rb in reactor-0.6.2 vs spec/models/concerns/subscribable_spec.rb in reactor-0.7.0

- old
+ new

@@ -20,10 +20,16 @@ def self.ring_bell(event) pp "ring ring! #{event}" end end +Reactor.in_test_mode do + class TestModeAuction < ActiveRecord::Base + on_event :test_puppy_delivered, -> (event) { pp "success" } + end +end + describe Reactor::Subscribable do let(:scheduled) { Sidekiq::ScheduledSet.new } describe 'on_event' do it 'binds block of code statically to event being fired' do @@ -69,9 +75,22 @@ end it 'fires perform_async when falsey' do Reactor::StaticSubscribers::WildcardHandler0.should_receive(:perform_async) Reactor::Event.publish(:puppy_delivered) + end + end + + describe '#perform' do + it 'returns :__perform_aborted__ when Reactor is in test mode' do + Reactor::StaticSubscribers::TestPuppyDeliveredHandler0.new.perform({}).should == :__perform_aborted__ + Reactor::Event.publish(:test_puppy_delivered) + end + + it 'performs normally when specifically enabled' do + Reactor.enable_test_mode_subscriber(TestModeAuction) + Reactor::StaticSubscribers::TestPuppyDeliveredHandler0.new.perform({}).should_not == :__perform_aborted__ + Reactor::Event.publish(:test_puppy_delivered) end end end end