spec/unit/channel_connector_spec.rb in pwwka-0.21.1 vs spec/unit/channel_connector_spec.rb in pwwka-0.21.2
- old
+ new
@@ -10,10 +10,11 @@
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(:close)
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)
@@ -41,9 +42,27 @@
expect(Bunny).to receive(:new).with(
/amqp:\/\/guest:guest@localhost:/,
{:automatically_recover=>false, :allow_delayed=>true})
described_class.new
+ end
+
+ context "error during connection start" do
+ before do
+ allow(bunny_session).to receive(:start).and_raise("Connection Error!")
+ end
+ it "closes the connection" do
+ begin
+ described_class.new
+ rescue => ex
+ end
+ expect(bunny_session).to have_received(:close)
+ end
+ it "raises an error" do
+ expect {
+ described_class.new
+ }.to raise_error(/Connection Error!/)
+ end
end
end
describe "raise_if_delayed_not_allowed" do