Sha256: fee11aaf46bb4835235132583384f578870368ddc4e2e49540c037e867a130ce

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

require "spec_helper"

describe Bunny::Channel, "#reject" do
  let(:connection) do
    c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
    c.start
    c
  end

  after :all do
    connection.close if connection.open?
  end

  subject do
    connection.create_channel
  end

  context "with requeue = true" do
    it "requeues a message" do
      q = subject.queue("bunny.basic.reject.manual-acks", :exclusive => true)
      x = subject.default_exchange

      x.publish("bunneth", :routing_key => q.name)
      sleep(0.5)
      q.message_count.should == 1
      delivery_info, _, _ = q.pop(:ack => true)

      subject.reject(delivery_info.delivery_tag, true)
      sleep(0.5)
      q.message_count.should == 1

      subject.close
    end
  end

  context "with requeue = false" do
    it "rejects a message" do
      q = subject.queue("bunny.basic.reject.with-requeue-false", :exclusive => true)
      x = subject.default_exchange

      x.publish("bunneth", :routing_key => q.name)
      sleep(0.5)
      q.message_count.should == 1
      delivery_info, _, _ = q.pop(:ack => true)

      subject.reject(delivery_info.delivery_tag, false)
      sleep(0.5)
      q.message_count.should == 0

      subject.close
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bunny-0.9.0.pre6 spec/higher_level_api/integration/basic_reject_spec.rb
bunny-0.9.0.pre5 spec/higher_level_api/integration/basic_reject_spec.rb
bunny-0.9.0.pre4 spec/higher_level_api/integration/basic_reject_spec.rb
bunny-0.9.0.pre3 spec/higher_level_api/integration/basic_reject_spec.rb
bunny-0.9.0.pre2 spec/higher_level_api/integration/basic_reject_spec.rb
bunny-0.9.0.pre1 spec/higher_level_api/integration/basic_reject_spec.rb