Sha256: 3b9570c453575933c3d5551567e0fa1a2cf25d3c8f52c532bba55985b8327b19

Contents?: true

Size: 946 Bytes

Versions: 58

Compression:

Stored size: 946 Bytes

Contents

require "spec_helper"

describe "Registering 2nd exclusive consumer on queue" do
  let(:connection) do
    c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
    c.start
    c
  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

    lambda do
      q2.subscribe(:exclusive => true) do |_, _, _|
      end
    end.should raise_error(Bunny::AccessRefused)

    ch1.should be_open
    ch2.should be_closed

    q1.publish("abc")
    sleep 0.1

    # verify that the first consumer is fine
    xs.should == ["abc"]

    q1.delete
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
bunny-1.7.1 spec/issues/issue141_spec.rb
bunny-1.7.0 spec/issues/issue141_spec.rb
bunny-1.6.3 spec/issues/issue141_spec.rb
bunny-1.6.2 spec/issues/issue141_spec.rb
bunny-1.6.1 spec/issues/issue141_spec.rb
bunny-1.6.0 spec/issues/issue141_spec.rb
bunny-1.5.1 spec/issues/issue141_spec.rb
bunny-1.6.0.rc2 spec/issues/issue141_spec.rb
bunny-1.6.0.rc1 spec/issues/issue141_spec.rb
bunny-1.6.0.pre1 spec/issues/issue141_spec.rb
bunny-1.5.0 spec/issues/issue141_spec.rb
bunny-1.5.0.pre2 spec/issues/issue141_spec.rb
bunny-1.5.0.pre1 spec/issues/issue141_spec.rb
bunny-1.4.1 spec/issues/issue141_spec.rb
bunny-1.4.0 spec/issues/issue141_spec.rb
bunny-1.3.1 spec/issues/issue141_spec.rb
bunny-1.3.0 spec/issues/issue141_spec.rb
bunny-1.2.2 spec/issues/issue141_spec.rb
bunny-1.2.1 spec/issues/issue141_spec.rb
bunny-1.2.0 spec/issues/issue141_spec.rb