Sha256: 9c7cc3d45fa35b28c6046c533f0692fbf7ab4e9696fd5e307ecbf128e6ea20b5
Contents?: true
Size: 1.79 KB
Versions: 6
Compression:
Stored size: 1.79 KB
Contents
require 'spec_helper.rb' # Most of this class is just interacting with Rabbit so it's covered # by the integration tests. describe Pwwka::ChannelConnector do let(:bunny_session) { instance_double(Bunny::Session) } subject(:channel_connector) { described_class.new } describe "initialize" do let(:bunny_channel) { instance_double(Bunny::Channel) } before do allow(Bunny).to receive(:new).and_return(bunny_session) allow(bunny_session).to receive(:start) allow(bunny_session).to receive(:create_channel).and_return(bunny_channel) end it "sets a prefetch value if configured to do so" do expect(bunny_channel).to receive(:prefetch).with(10) described_class.new(prefetch: 10) end it "does not set a prefetch value unless configured" do expect(bunny_channel).not_to receive(:prefetch).with(10) described_class.new end end describe "raise_if_delayed_not_allowed" do before do allow(Bunny).to receive(:new).and_return(bunny_session) allow(bunny_session).to receive(:start) allow(bunny_session).to receive(:create_channel) @default_allow_delayed = Pwwka.configuration.options[:allow_delayed] end after do Pwwka.configuration.options[:allow_delayed] = @default_allow_delayed end context "delayed is configured" do it "does not blow up" do Pwwka.configuration.options[:allow_delayed] = true expect { channel_connector.raise_if_delayed_not_allowed }.not_to raise_error end end context "delayed is not configured" do it "blows up" do Pwwka.configuration.options[:allow_delayed] = false expect { channel_connector.raise_if_delayed_not_allowed }.to raise_error(Pwwka::ConfigurationError) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems