spec/mongo/operation/read_preference_spec.rb in mongo-2.2.7 vs spec/mongo/operation/read_preference_spec.rb in mongo-2.3.0

- old
+ new

@@ -24,22 +24,22 @@ let(:read_pref) do Mongo::ServerSelector.get end - let(:read_preference) do + let(:operation) do Class.new do include Mongo::Operation::ReadPreference end.new.tap do |rp| allow(rp).to receive(:read).and_return(read_pref) allow(rp).to receive(:selector).and_return(selector) allow(rp).to receive(:options).and_return(options) end end - let(:context) do - double('context').tap do |c| + let(:server) do + double('server').tap do |c| allow(c).to receive(:cluster).and_return(cluster_double) allow(cluster_double).to receive(:single?).and_return(single?) allow(c).to receive(:mongos?).and_return(mongos?) end end @@ -53,11 +53,11 @@ let(:expected) do { :$query => selector, :$readPreference => read_pref.to_mongos } end it 'returns a special selector' do - expect(read_preference.send(:update_selector, context)).to eq(expected) + expect(operation.send(:update_selector, server)).to eq(expected) end context 'when the selector already has $query in it' do let(:selector) do @@ -68,11 +68,11 @@ let(:expected) do selector.merge(:$readPreference => read_pref.to_mongos) end it 'returns an unaltered special selector' do - expect(read_preference.send(:update_selector, context)).to eq(expected) + expect(operation.send(:update_selector, server)).to eq(expected) end end end shared_context 'not a selector updater' do @@ -80,11 +80,11 @@ let(:read_pref) do Mongo::ServerSelector.get(:mode => mode) end it 'returns a selector' do - expect(read_preference.send(:update_selector, context)).to eq(selector) + expect(operation.send(:update_selector, server)).to eq(selector) end end context 'when the server is a mongos' do @@ -166,11 +166,11 @@ let(:expected) do { } end it 'does not set the slave_ok flag' do - expect(read_preference.send(:update_options, context)).to eq(expected) + expect(operation.send(:update_options, server)).to eq(expected) end end context 'when the server is not a mongos' do @@ -181,11 +181,11 @@ let(:expected) do { :flags => [ :slave_ok ] } end it 'sets the slave_ok flag' do - expect(read_preference.send(:update_options, context)).to eq(expected) + expect(operation.send(:update_options, server)).to eq(expected) end end end context 'when the topology is not Single' do @@ -203,11 +203,11 @@ let(:expected) do { } end it 'does not set the slave_ok flag' do - expect(read_preference.send(:update_options, context)).to eq(expected) + expect(operation.send(:update_options, server)).to eq(expected) end end context 'when there is a read preference' do @@ -220,11 +220,11 @@ let(:expected) do { :flags => [ :slave_ok ] } end it 'sets the slave_ok flag' do - expect(read_preference.send(:update_options, context)).to eq(expected) + expect(operation.send(:update_options, server)).to eq(expected) end end context 'when the read preference does not require the slave_ok flag' do @@ -235,10 +235,10 @@ let(:expected) do { } end it 'does not set the slave_ok flag' do - expect(read_preference.send(:update_options, context)).to eq(expected) + expect(operation.send(:update_options, server)).to eq(expected) end end end end end