spec/models/concerns/subscribable_spec.rb in reactor-0.4.0 vs spec/models/concerns/subscribable_spec.rb in reactor-0.4.2

- old
+ new

@@ -14,10 +14,11 @@ pp "ring ring! #{event}" 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 Auction.any_instance.should_receive(:update_column).with(:status, 'first_bid_made') Reactor::Event.publish(:bid_made, target: Auction.create) @@ -28,11 +29,11 @@ Auction.should_receive(:ring_bell) Reactor::Event.publish(:puppy_delivered) end it 'can be delayed', :sidekiq do - Reactor::Event.process(:pooped, {}) - job = Reactor::Event.scheduled_jobs(from: 4.minutes.from_now, to: 6.minutes.from_now).last + Reactor::Event.perform('pooped', {}) + job = scheduled.detect{|job| job.score > 4.minutes.from_now.to_f && job.score <= 5.minutes.from_now.to_f } job.should be_present job['args'].last.should include("pick_up_poop") end end \ No newline at end of file