spec/lib/wisper/publisher_spec.rb in wisper-2.0.0.rc1 vs spec/lib/wisper/publisher_spec.rb in wisper-2.0.0

- old
+ new

@@ -209,18 +209,31 @@ end it 'is aliased to .subscribe' do expect(publisher).to respond_to(:subscribe) end + + it 'raises a helpful error if trying to pass a block' do + invalid = ->{ + publisher.subscribe(:success) do + puts + end + } + expect{ invalid.call }.to raise_error(ArgumentError) + end end describe '.on' do it 'returns publisher so methods can be chained' do expect(publisher.on('this_thing_happened') {}).to eq publisher end it 'raise an error if no events given' do expect { publisher.on() {} }.to raise_error(ArgumentError) + end + + it 'raises an error of no block given' do + expect { publisher.on(:something) }.to raise_error(ArgumentError) end it 'returns publisher so methods can be chained' do expect(publisher.on(:foo) {}).to eq publisher end