diff --git a/lib/mongo/server/connection_pool.rb b/lib/mongo/server/connection_pool.rb index 01913ab81e..b65a2e7547 100644 --- a/lib/mongo/server/connection_pool.rb +++ b/lib/mongo/server/connection_pool.rb @@ -984,7 +984,7 @@ def maybe_raise_pool_cleared!(connection, e) # Attempts to connect (handshake and auth) the connection. If an error is # encountered, closes the connection and raises the error. - def connect_connection(connection, context) + def connect_connection(connection, context = nil) begin connection.connect!(context) rescue Exception diff --git a/spec/mongo/operation/context_spec.rb b/spec/mongo/operation/context_spec.rb index 5a051e4995..4c2d692042 100644 --- a/spec/mongo/operation/context_spec.rb +++ b/spec/mongo/operation/context_spec.rb @@ -34,7 +34,7 @@ context 'when timeout_ms is positive' do before do - expect(Mongo::Utils).to receive(:monotonic_time).and_return(100.0) + allow(Mongo::Utils).to receive(:monotonic_time).and_return(100.0) end let(:timeout_ms) { 10_000 } @@ -46,7 +46,9 @@ end describe '#remaining_timeout_ms' do - let(:context) { described_class.new(timeout_ms: timeout_ms) } + let(:context) { + described_class.new(timeout_ms: timeout_ms) + } context 'when timeout_ms is nil' do let(:timeout_ms) { nil } @@ -66,8 +68,8 @@ context 'when timeout_ms is positive' do before do - expect(Mongo::Utils).to receive(:monotonic_time).ordered.and_return(100.0) - expect(Mongo::Utils).to receive(:monotonic_time).ordered.and_return(105.0) + allow(Mongo::Utils).to receive(:monotonic_time).ordered.and_return([100.0, 105.0]) + # allow(Mongo::Utils).to receive(:monotonic_time).ordered.and_return(105.0) end let(:timeout_ms) { 10_000 }