Sha256: 3f9464cd127b4c9e953684d40f4c72f8dd7adf16cee6846bbd70b6487be417d9
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
require 'spec_helper' # Example class MyCommand include Wisper 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wisper-1.0.1 | spec/lib/integration_spec.rb |