spec/invoker/event/manager_spec.rb in invoker-1.0.2 vs spec/invoker/event/manager_spec.rb in invoker-1.0.3
- old
+ new
@@ -9,40 +9,35 @@
it "should run matched events" do
@event_manager.schedule_event("foo", :exit) { 'exit foo' }
@event_manager.trigger("foo", :exit)
@event_manager.run_scheduled_events do |event|
- event.block.call.should.equal("exit foo")
+ expect(event.block.call).to eq("exit foo")
end
- @event_manager.scheduled_events.should.be.empty
- @event_manager.triggered_events.should.be.empty
+ expect(@event_manager.scheduled_events).to be_empty
+ expect(@event_manager.triggered_events).to be_empty
end
it "should remove triggrered and scheduld events on run" do
@event_manager.schedule_event("foo", :exit) { 'exit foo' }
@event_manager.schedule_event("bar", :entry) { "entry bar"}
@event_manager.trigger("foo", :exit)
@event_manager.trigger("baz", :exit)
@event_manager.run_scheduled_events do |event|
- event.block.call.should.equal("exit foo")
+ expect(event.block.call).to eq("exit foo")
end
- @event_manager.scheduled_events.should.not.be.empty
- @event_manager.triggered_events.should.not.be.empty
+ expect(@event_manager.scheduled_events).not_to be_empty
+ expect(@event_manager.triggered_events).not_to be_empty
- baz_containing_event = lambda do |events|
- events.detect {|event| event.command_label == "baz" }
- end
+ baz_containing_event = @event_manager.triggered_events.map(&:command_label)
+ expect(baz_containing_event).to include("baz")
- bar_containing_scheduled_event = lambda do |events|
- events.keys.detect {|event_key| event_key == "bar" }
- end
-
- @event_manager.triggered_events.should.be.a baz_containing_event
- @event_manager.scheduled_events.should.be.a bar_containing_scheduled_event
+ bar_containing_scheduled_event = @event_manager.scheduled_events.keys
+ expect(bar_containing_scheduled_event).to include("bar")
end
it "should handle multiple events for same command" do
@event_manager.schedule_event("foo", :exit) { 'exit foo' }
@event_manager.schedule_event("foo", :entry) { "entry bar"}
@@ -52,21 +47,21 @@
@event_manager.schedule_event("foo", :exit) { 'exit foo' }
@event_manager.trigger("foo", :exit)
- @event_manager.scheduled_events.should.not.be.empty
- @event_manager.triggered_events.should.not.be.empty
+ expect(@event_manager.scheduled_events).not_to be_empty
+ expect(@event_manager.triggered_events).not_to be_empty
end
it "should not run unmatched events" do
@event_manager.schedule_event("bar", :entry) { "entry bar"}
@event_manager.trigger("foo", :exit)
events_ran = false
@event_manager.run_scheduled_events do |event|
events_ran = true
end
- events_ran.should.be.false
+ expect(events_ran).to be_false
end
end
end