spec/qsagi/queue_spec.rb in qsagi-0.0.3 vs spec/qsagi/queue_spec.rb in qsagi-0.1.0

- old
+ new

@@ -10,11 +10,11 @@ end describe "self.exchange" do it "configures the exchange" do queue_on_exchange1 = Class.new(ExampleQueue) do - exchange "exchange1" + exchange "exchange1", :type => :direct end queue_on_exchange2 = Class.new(ExampleQueue) do exchange "exchange2" end queue_on_exchange1.connect do |queue| @@ -52,10 +52,34 @@ queue.length.should == 1 end end end + describe "reject" do + it "rejects the message and places it back on the queue" do + ExampleQueue.connect do |queue| + queue.push("message") + message = queue.pop(:auto_ack => false) + queue.reject(message, :requeue => true) + end + ExampleQueue.connect do |queue| + queue.length.should == 1 + end + end + + it "rejects and discards the message" do + ExampleQueue.connect do |queue| + queue.push("message") + message = queue.pop(:auto_ack => false) + queue.reject(message, :requeue => false) + end + ExampleQueue.connect do |queue| + queue.length.should == 0 + end + end + end + describe "pop" do it "automatically acks if :auto_ack is not passed in" do ExampleQueue.connect do |queue| queue.push("message") message = queue.pop @@ -79,9 +103,19 @@ queue.ack(message) end ExampleQueue.connect do |queue| message = queue.pop(:auto_ack => false) message.should == nil + end + end + end + + describe "queue_type confirmed" do + it "should use a ConfirmedQueue" do + ExampleQueue.connect(:queue_type => :confirmed) do |queue| + queue.push("message") + queue.wait_for_confirms + queue.nacked_messages.size.should == 0 end end end end