spec/lib/integration_spec.rb in wisper-0.0.2 vs spec/lib/integration_spec.rb in wisper-1.0.0

- old
+ new

@@ -36,6 +36,33 @@ insider.render(message) end command.execute(true) end + + it 'maps events to different methods' do + listener_1 = double('listener') + listener_2 = double('listener') + listener_1.should_receive(:happy_days).with('hello') + listener_2.should_receive(:sad_days).with('world') + + command = MyCommand.new + + command.add_listener(listener_1, :on => :success, :with => :happy_days) + command.add_listener(listener_2, :on => :failure, :with => :sad_days) + + command.execute(true) + command.execute(false) + end + + it 'subscribes block can be chained' do + insider = double('Insider') + insider.should_receive(:render).with('success') + + command = MyCommand.new + + command.on(:success) { |message| insider.render('success') } + .on(:failure) { |message| insider.render('failure') } + + command.execute(true) + end end