Skip to content

Commit 909d21d

Browse files
committed
Fix test race condition
1 parent 0334f3a commit 909d21d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

spec/mongo/server/connection_spec.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,6 @@
546546

547547
before do
548548
connection.connect!
549-
socket = connection.instance_variable_get(:@socket)
550-
max_message_size = connection.send(:max_message_size)
551-
allow(Mongo::Protocol::Reply).to receive(:deserialize).with(socket, max_message_size).and_return(reply)
552549
end
553550

554551
context 'when the ismaster response indicates the auth mechanism is :scram' do
@@ -564,13 +561,19 @@
564561
context 'when the server auth mechanism is scram', if: scram_sha_1_enabled? do
565562

566563
it 'uses scram' do
564+
socket = connection.instance_variable_get(:@socket)
565+
max_message_size = connection.send(:max_message_size)
566+
allow(Mongo::Protocol::Reply).to receive(:deserialize).with(socket, max_message_size).and_return(reply)
567567
expect(connection.send(:default_mechanism)).to eq(:scram)
568568
end
569569
end
570570

571571
context 'when the server auth mechanism is the default (mongodb_cr)', unless: scram_sha_1_enabled? do
572572

573573
it 'uses scram' do
574+
socket = connection.instance_variable_get(:@socket)
575+
max_message_size = connection.send(:max_message_size)
576+
allow(Mongo::Protocol::Reply).to receive(:deserialize).with(socket, max_message_size).and_return(reply)
574577
expect(connection.send(:default_mechanism)).to eq(:scram)
575578
end
576579
end
@@ -589,13 +592,19 @@
589592
context 'when the server auth mechanism is scram', if: scram_sha_1_enabled? do
590593

591594
it 'uses scram' do
595+
socket = connection.instance_variable_get(:@socket)
596+
max_message_size = connection.send(:max_message_size)
597+
allow(Mongo::Protocol::Reply).to receive(:deserialize).with(socket, max_message_size).and_return(reply)
592598
expect(connection.send(:default_mechanism)).to eq(:scram)
593599
end
594600
end
595601

596602
context 'when the server auth mechanism is the default (mongodb_cr)', unless: scram_sha_1_enabled? do
597603

598604
it 'uses mongodb_cr' do
605+
socket = connection.instance_variable_get(:@socket)
606+
max_message_size = connection.send(:max_message_size)
607+
allow(Mongo::Protocol::Reply).to receive(:deserialize).with(socket, max_message_size).and_return(reply)
599608
expect(connection.send(:default_mechanism)).to eq(:mongodb_cr)
600609
end
601610
end

0 commit comments

Comments
 (0)