Sha256: 8b6dcf2f72d482f45b1da4ffde29e27babb34e21cf8312c41ca3b038fca1c47f

Contents?: true

Size: 1.4 KB

Versions: 20

Compression:

Stored size: 1.4 KB

Contents

require "spec_helper"

describe Bunny::Channel, "#ack" 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 a valid (known) delivery tag" do
    it "acknowleges a message" do
      q = subject.queue("bunny.basic.ack.manual-acks", :exclusive => true)
      x = subject.default_exchange

      x.publish("bunneth", :routing_key => q.name)
      sleep(0.25)
      q.message_count.should == 1
      delivery_details, properties, content = q.pop(:ack => true)

      subject.ack(delivery_details.delivery_tag, true)
      sleep(0.25)
      q.message_count.should == 0

      subject.close
    end
  end

  context "with an invalid (random) delivery tag" do
    it "causes a channel-level error" do
      q = subject.queue("bunny.basic.ack.unknown-delivery-tag", :exclusive => true)
      x = subject.default_exchange

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

      subject.on_error do |ch, channel_close|
        @channel_close = channel_close
      end
      subject.ack(82, true)

      sleep 0.5

      @channel_close.reply_text.should == "PRECONDITION_FAILED - unknown delivery tag 82"
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
bunny-0.9.8 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-1.0.0.pre2 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.7 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.6 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.5 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.4 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-1.0.0.pre1 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.3 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.2 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.1 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.0 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.0.rc2 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.0.rc1 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.0.pre13 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.0.pre12 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.0.pre11 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.0.pre10 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.0.pre9 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.0.pre8 spec/higher_level_api/integration/basic_ack_spec.rb
bunny-0.9.0.pre7 spec/higher_level_api/integration/basic_ack_spec.rb