Skip to content

Commit

Permalink
add disconnected coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bedrock-adam committed Jan 14, 2024
1 parent c3d6c55 commit 36da040
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions spec/outboxer/publisher/disconnect_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'spec_helper'

module Outboxer
RSpec.describe Publisher do
describe '.disconnect!' do
context 'when successful' do
it 'does not raise an error' do
expect { Publisher.disconnect! }.not_to raise_error
end

it 'returns connected false' do
Publisher.disconnect!

expect(Publisher.connected?).to be false
end
end

context 'when not successful' do
before do
allow(ActiveRecord::Base.connection_handler)
.to receive(:clear_active_connections!).and_raise(ActiveRecord::ConnectionNotEstablished)
end

it 'raises a DisconnectError' do
expect { Publisher.disconnect! }.to raise_error(Publisher::DisconnectError)
end
end
end
end
end

0 comments on commit 36da040

Please sign in to comment.