Sha256: 3bf48b34c145b0e6e127ac62f523435c442c519b561992a54e4f4f3a4e0abcc7

Contents?: true

Size: 1.76 KB

Versions: 19

Compression:

Stored size: 1.76 KB

Contents

require "spec_helper"

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

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

  let(:n) { 200 }

  context "when publishing with confirms enabled" do
    it "increments delivery index" do
      ch = connection.create_channel
      ch.should_not be_using_publisher_confirmations

      ch.confirm_select
      ch.should be_using_publisher_confirmations

      q  = ch.queue("", :exclusive => true)
      x  = ch.default_exchange

      n.times do
        x.publish("xyzzy", :routing_key => q.name)
      end

      ch.next_publish_seq_no.should == n + 1
      ch.wait_for_confirms.should be_true
      sleep 0.25

      q.message_count.should == n
      q.purge

      ch.close
    end
  end


  context "with a single-threaded connection" do
    let(:connection) do
      c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed", :continuation_timeout => 10000, :threaded => false)
      c.start
      c
    end


    context "when publishing with confirms enabled" do
      it "increments delivery index" do
        ch = connection.create_channel
        ch.should_not be_using_publisher_confirmations

        ch.confirm_select
        ch.should be_using_publisher_confirmations

        q  = ch.queue("", :exclusive => true)
        x  = ch.default_exchange

        n.times do
          x.publish("xyzzy", :routing_key => q.name)
        end

        ch.next_publish_seq_no.should == n + 1
        ch.wait_for_confirms.should be_true
        sleep 0.25

        q.message_count.should == n
        q.purge

        ch.close
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
bunny-1.3.1 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.3.0 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.2.2 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.2.1 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.2.0 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.1.9 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.1.8 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.1.7 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.1.6 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.1.5 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.1.4 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.1.3 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.1.2 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.1.1 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.1.0 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.1.0.rc1 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.0.7 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.0.6 spec/higher_level_api/integration/publisher_confirms_spec.rb
bunny-1.0.5 spec/higher_level_api/integration/publisher_confirms_spec.rb