diff --git a/lib/moqueue/mock_queue.rb b/lib/moqueue/mock_queue.rb index bea053e..9661c9b 100644 --- a/lib/moqueue/mock_queue.rb +++ b/lib/moqueue/mock_queue.rb @@ -50,7 +50,7 @@ def received_routing_key?(key) end def unsubscribe - true + @subscribe_block = nil end def prefetch(size) diff --git a/spec/unit/mock_queue_spec.rb b/spec/unit/mock_queue_spec.rb index e3bcfd1..a3c9c92 100644 --- a/spec/unit/mock_queue_spec.rb +++ b/spec/unit/mock_queue_spec.rb @@ -94,6 +94,13 @@ @queue.should respond_to(:unsubscribe) end + it "should prevent double subscribe errors if unsubscribe is called inbetween" do + @queue.subscribe { |msg| "once" } + @queue.unsubscribe + @queue.subscribe { |msg| "second" }.should_not raise_error(DoubleSubscribeError) + end + + it "should ignore #prefetch but at least raise an error" do lambda { @queue.prefetch(1337) }.should_not raise_error end