spec/microevent_spec.rb in microevent-1.0.2 vs spec/microevent_spec.rb in microevent-1.1.0

- old
+ new

@@ -137,33 +137,33 @@ object.trigger :slot assert_equal [23], result end - it "will do nothing if there is nothing to remove" do - result = [] - - object.unbind :slot - - assert_equal [], result - end - it "returns deleted callbacks" do fn = proc{} object.bind :slot, &fn result = object.unbind :slot, &fn assert_equal fn, result end it "will return nil if nothing is removed" do fn = proc{} + object.bind :another_slot, &fn result = object.unbind :slot, &fn assert_equal nil, result end + it "will return nil if no callback is registered at all" do + fn = proc{} + result = object.unbind :slot, &fn + + assert_equal nil, result + end + it 'will delete all callbacks if no block is given' do result = [] fn = proc{ result << 42 } fn2 = proc{ result << 23 } @@ -184,14 +184,22 @@ assert_equal [fn, fn2], result end it 'will return emtpy array if no block is given and no callback deleted' do + fn = proc{} + object.bind :another_slot, &fn result = object.unbind :slot assert_equal [], result end + + it 'will return emtpy array if no block is given and no callback is registered at all' do + result = object.unbind :slot + + assert_equal [], result + end end describe '#trigger details' do it "will do nothing if no callback is registered" do result = [] @@ -208,9 +216,17 @@ assert_equal true, result end it "will return false if there is no callback listening" do + fn = proc{} + object.bind :other_slot, &fn + result = object.trigger :slot + + assert_equal false, result + end + + it "will return false if there is no callback at all registered" do result = object.trigger :slot assert_equal false, result end end