Sha256: 62bd3305293e44e08af3045533d3a19d964d19e22f86556bbb01289a75acf69b

Contents?: true

Size: 961 Bytes

Versions: 30

Compression:

Stored size: 961 Bytes

Contents

require "spec_helper"

describe "Registering 2nd exclusive consumer on queue" do
    before :all do
    @connection = Bunny.new(:user => "bunny_gem", password:  "bunny_password", :vhost => "bunny_testbed")
    @connection.start
  end

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


  it "raises a meaningful exception" do
    xs  = []

    ch1 = @connection.create_channel
    ch2 = @connection.create_channel
    q1  = ch1.queue("", :auto_delete => true)
    q2  = ch2.queue(q1.name, :auto_delete => true, :passive => true)

    c1  = q1.subscribe(exclusive: true) do |_, _, payload|
      xs << payload
    end
    sleep 0.1

    expect do
      q2.subscribe(exclusive: true) do |_, _, _|
      end
    end.to raise_error(Bunny::AccessRefused)

    expect(ch1).to be_open
    expect(ch2).to be_closed

    q1.publish("abc")
    sleep 0.1

    # verify that the first consumer is fine
    expect(xs).to eq ["abc"]

    q1.delete
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
bunny-2.19.0 spec/issues/issue141_spec.rb
bunny-2.18.0 spec/issues/issue141_spec.rb
bunny-2.17.0 spec/issues/issue141_spec.rb
bunny-2.16.1 spec/issues/issue141_spec.rb
bunny-2.15.0 spec/issues/issue141_spec.rb
bunny-2.14.4 spec/issues/issue141_spec.rb
bunny-2.14.3 spec/issues/issue141_spec.rb
bunny-2.14.2 spec/issues/issue141_spec.rb
bunny-2.14.1 spec/issues/issue141_spec.rb
bunny-2.13.0 spec/issues/issue141_spec.rb
bunny-2.12.1 spec/issues/issue141_spec.rb
bunny-2.12.0 spec/issues/issue141_spec.rb
bunny-2.12.0.rc1 spec/issues/issue141_spec.rb
bunny-2.11.0 spec/issues/issue141_spec.rb
bunny-2.11.0.pre1 spec/issues/issue141_spec.rb
bunny-2.10.0 spec/issues/issue141_spec.rb
bunny-2.9.2 spec/issues/issue141_spec.rb
bunny-2.9.1 spec/issues/issue141_spec.rb
bunny-2.6.7 spec/issues/issue141_spec.rb
bunny-2.7.4 spec/issues/issue141_spec.rb