Sha256: 8fdf2acc289aa384ca50d566fffb97a9306b55e6bd04787d14e43b10d4c617a3
Contents?: true
Size: 1.6 KB
Versions: 4
Compression:
Stored size: 1.6 KB
Contents
require 'spec_helper' # Example class MyCommand include Wisper::Publisher def execute(be_successful) if be_successful broadcast('success', 'hello') else broadcast('failure', 'world') end end end describe Wisper do it 'subscribes object to all published events' do listener = double('listener') listener.should_receive(:success).with('hello') command = MyCommand.new command.add_listener(listener) command.execute(true) end it 'subscribes block to all published events' do insider = double('Insider') insider.should_receive(:render).with('hello') command = MyCommand.new command.add_block_listener do |message| 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') insider.should_receive(:render).with('failure') command = MyCommand.new command.on(:success) { |message| insider.render('success') } .on(:failure) { |message| insider.render('failure') } command.execute(true) command.execute(false) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
wisper-1.3.0 | spec/lib/integration_spec.rb |
wisper-1.2.1 | spec/lib/integration_spec.rb |
wisper-1.2.0 | spec/lib/integration_spec.rb |
wisper-1.1.0 | spec/lib/integration_spec.rb |