Sha256: 51510200d8c8e55dc6a81c1b20cc992fff511f956bb7de82838437fa9ba782be
Contents?: true
Size: 1.62 KB
Versions: 21
Compression:
Stored size: 1.62 KB
Contents
require 'logstash-logger' describe LogStashLogger::Device::Connectable do include_context 'device' let(:io) { double("IO") } subject { udp_device } describe "#reconnect" do context "with active IO connection" do before do subject.instance_variable_set(:@io, io) end it "closes the connection" do expect(io).to receive(:close).once subject.reconnect end end context "with no active IO connection" do before do subject.instance_variable_set(:@io, nil) end it "does nothing" do expect(io).to_not receive(:close) subject.reconnect end end end describe "#with_connection" do context "on exception" do before do allow(subject).to receive(:connected?) { raise(StandardError) } allow(subject).to receive(:warn) end context "with active IO connection" do before do subject.instance_variable_set(:@io, io) end it "closes the connection" do expect(io).to receive(:close).once expect { subject.with_connection do |connection| connection end }.to raise_error(StandardError) end end context "with no active IO connection" do before do subject.instance_variable_set(:@io, nil) end it "does nothing" do expect(io).to_not receive(:close) expect { subject.with_connection do |connection| connection end }.to raise_error(StandardError) end end end end end
Version data entries
21 entries across 21 versions & 3 rubygems