lib/reactor/testing/matchers.rb in reactor-0.2.6 vs lib/reactor/testing/matchers.rb in reactor-0.2.7

- old
+ new

@@ -1,13 +1,25 @@ RSpec::Matchers.define :publish_event do |name, data = {}| match do |block| - if data.empty? - Reactor::Event.should_receive(:publish).with do |*args| - args.first.should == name + defaults = {:actor => anything, :target => anything} + Reactor::Event.should_receive(:publish).with(name, defaults.merge(data)) + block.call + end +end + +RSpec::Matchers.define :publish_events do |*args| + + match do |block| + defaults = {:actor => anything, :target => anything} + + args.each do |event| + case event + when Symbol + Reactor::Event.should_receive(:publish).with(event, anything) + when Hash + Reactor::Event.should_receive(:publish).with(event.keys.first, defaults.merge(event.values.first)) end - else - Reactor::Event.should_receive(:publish).with(name, data) end block.call end end \ No newline at end of file