Sha256: 920c832793575fd6e77271a2f3e2669f228edc6f24c59e330ccbb9d8706bdb74

Contents?: true

Size: 1.59 KB

Versions: 30

Compression:

Stored size: 1.59 KB

Contents

require "spec_helper"

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

  after :each do
    connection.close
  end

  context "with a positive integer < 65535" do
    it "sets that prefetch level via basic.qos" do
      ch = connection.create_channel
      expect(ch.prefetch_count).not_to eq 10
      expect(ch.prefetch_global).to be_nil
      expect(ch.prefetch(10)).to be_instance_of(AMQ::Protocol::Basic::QosOk)
      expect(ch.prefetch_count).to eq 10
      expect(ch.prefetch_global).to be false
    end

    it "sets that prefetch global via basic.qos" do
      ch = connection.create_channel
      expect(ch.prefetch_count).not_to eq 42
      expect(ch.prefetch_global).to be_nil
      expect(ch.prefetch(42, true)).to be_instance_of(AMQ::Protocol::Basic::QosOk)
      expect(ch.prefetch_count).to eq 42
      expect(ch.prefetch_global).to be true
    end
  end

  context "with a positive integer > 65535" do
    it "raises an ArgumentError" do
      ch = connection.create_channel
      expect {
        ch.prefetch(100_000)
      }.to raise_error(
        ArgumentError,
        "prefetch count must be no greater than #{Bunny::Channel::MAX_PREFETCH_COUNT}, given: 100000"
      )
    end
  end

  context "with a negative integer" do
    it "raises an ArgumentError" do
      ch = connection.create_channel
      expect {
        ch.prefetch(-2)
      }.to raise_error(
        ArgumentError,
        "prefetch count must be a positive integer, given: -2"
      )
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

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