spec/mongo/operation/delete/op_msg_spec.rb in mongo-2.10.5 vs spec/mongo/operation/delete/op_msg_spec.rb in mongo-2.11.0.rc0
- old
+ new
@@ -141,29 +141,36 @@
expect(Mongo::Protocol::Msg).to receive(:new).with([], {}, expected_global_args, expected_payload_1)
op.send(:message, authorized_primary)
end
context 'when an implicit session is created and the topology is then updated and the server does not support sessions' do
+ # Mocks on features are incompatible with linting
+ skip_if_linting
let(:expected_global_args) do
global_args.dup.tap do |args|
args.delete(:lsid)
end
end
before do
session.instance_variable_set(:@options, { implicit: true })
# Topology is standalone, hence there is exactly one server
- authorized_client.cluster.servers.first.monitor.stop!(true)
- allow(authorized_primary.features).to receive(:sessions_enabled?).and_return(false)
+ authorized_primary.monitor.stop!
end
it 'creates the correct OP_MSG message' do
- authorized_client.command(ping:1)
- expect(expected_global_args[:session]).to be nil
- expect(Mongo::Protocol::Msg).to receive(:new).with([], {}, expected_global_args, expected_payload_1)
- op.send(:message, authorized_primary)
+ RSpec::Mocks.with_temporary_scope do
+ # Override description as it gets replaced on every connection
+ description = authorized_primary.description
+ allow(authorized_primary).to receive(:description).and_return(description)
+ allow(description.features).to receive(:sessions_enabled?).and_return(false)
+
+ expect(expected_global_args[:session]).to be nil
+ expect(Mongo::Protocol::Msg).to receive(:new).with([], {}, expected_global_args, expected_payload_1)
+ op.send(:message, authorized_primary)
+ end
end
end
end
context 'when the write concern is 0' do
@@ -230,11 +237,13 @@
end
end
it 'does not send a session id in the command' do
authorized_client.command(ping:1)
- expect(Mongo::Protocol::Msg).to receive(:new).with([:more_to_come], {}, expected_global_args, expected_payload_1)
- op.send(:message, authorized_primary)
+ RSpec::Mocks.with_temporary_scope do
+ expect(Mongo::Protocol::Msg).to receive(:new).with([:more_to_come], {}, expected_global_args, expected_payload_1)
+ op.send(:message, authorized_primary)
+ end
end
end
end
end
end