spec/mongo/collection_spec.rb in mongo-2.6.1 vs spec/mongo/collection_spec.rb in mongo-2.6.2
- old
+ new
@@ -99,11 +99,11 @@
end
describe '#with' do
let(:client) do
- Mongo::Client.new(ADDRESSES, TEST_OPTIONS)
+ Mongo::Client.new(SpecConfig.instance.addresses, TEST_OPTIONS)
end
let(:database) do
Mongo::Database.new(client, :test)
end
@@ -131,22 +131,22 @@
end
context 'when the client has a server selection timeout setting' do
let(:client) do
- Mongo::Client.new(ADDRESSES, TEST_OPTIONS.merge(server_selection_timeout: 2))
+ Mongo::Client.new(SpecConfig.instance.addresses, TEST_OPTIONS.merge(server_selection_timeout: 2))
end
it 'passes the the server_selection_timeout to the cluster' do
expect(client.cluster.options[:server_selection_timeout]).to eq(client.options[:server_selection_timeout])
end
end
context 'when the client has a read preference set' do
let(:client) do
- Mongo::Client.new(ADDRESSES, TEST_OPTIONS.merge(read: { mode: :primary_preferred }))
+ Mongo::Client.new(SpecConfig.instance.addresses, TEST_OPTIONS.merge(read: { mode: :primary_preferred }))
end
it 'sets the new read options on the new collection' do
expect(new_collection.read_preference).to eq(new_options[:read])
expect(new_collection.read_preference).not_to eq(client.read_preference)
@@ -154,11 +154,11 @@
end
context 'when the client has a read preference and server selection timeout set' do
let(:client) do
- Mongo::Client.new(ADDRESSES, TEST_OPTIONS.merge(read: { mode: :primary_preferred }, server_selection_timeout: 2))
+ Mongo::Client.new(SpecConfig.instance.addresses, TEST_OPTIONS.merge(read: { mode: :primary_preferred }, server_selection_timeout: 2))
end
it 'sets the new read options on the new collection' do
expect(new_collection.read_preference).to eq(new_options[:read])
end
@@ -184,11 +184,11 @@
end
context 'when the client has a write concern set' do
let(:client) do
- Mongo::Client.new(ADDRESSES, TEST_OPTIONS.merge(write: INVALID_WRITE_CONCERN))
+ Mongo::Client.new(SpecConfig.instance.addresses, TEST_OPTIONS.merge(write: INVALID_WRITE_CONCERN))
end
it 'sets the new write options on the new collection' do
expect(new_collection.write_concern.options).to eq(Mongo::WriteConcern.get(new_options[:write]).options)
end
@@ -217,22 +217,22 @@
end
context 'when the client has a server selection timeout setting' do
let(:client) do
- Mongo::Client.new(ADDRESSES, TEST_OPTIONS.merge(server_selection_timeout: 2))
+ Mongo::Client.new(SpecConfig.instance.addresses, TEST_OPTIONS.merge(server_selection_timeout: 2))
end
it 'passes the server_selection_timeout setting to the cluster' do
expect(client.cluster.options[:server_selection_timeout]).to eq(client.options[:server_selection_timeout])
end
end
context 'when the client has a read preference set' do
let(:client) do
- Mongo::Client.new(ADDRESSES, TEST_OPTIONS.merge(read: { mode: :primary_preferred }))
+ Mongo::Client.new(SpecConfig.instance.addresses, TEST_OPTIONS.merge(read: { mode: :primary_preferred }))
end
it 'sets the new read options on the new collection' do
expect(new_collection.read_preference).to eq(new_options[:read])
expect(new_collection.read_preference).not_to be(client.read_preference)
@@ -487,11 +487,12 @@
described_class.new(database, :specs, options)
end
it_behaves_like 'a capped collection command'
- context 'when validators can be set', if: find_command_enabled? do
+ context 'when validators can be set' do
+ min_server_version '3.2'
it_behaves_like 'a validated collection command'
end
end
context 'when instantiating a collection through the database' do
@@ -500,11 +501,12 @@
authorized_client[:specs, options]
end
it_behaves_like 'a capped collection command'
- context 'when validators can be set', if: find_command_enabled? do
+ context 'when validators can be set' do
+ min_server_version '3.2'
it_behaves_like 'a validated collection command'
end
end
end
@@ -1239,11 +1241,12 @@
expect(insert_events.size).to eq(1)
expect(insert_events[0].command['documents']).to eq(documents)
end
end
- context 'when collection has a validator', if: find_command_enabled? do
+ context 'when collection has a validator' do
+ min_server_version '3.2'
around(:each) do |spec|
authorized_client[:validating,
:validator => { :a => { '$exists' => true } }].tap do |c|
c.create
@@ -1444,11 +1447,12 @@
it 'inserts with the custom id' do
expect(custom_collection.find.first[:_id]).to eq(1)
end
end
- context 'when collection has a validator', if: find_command_enabled? do
+ context 'when collection has a validator' do
+ min_server_version '3.2'
around(:each) do |spec|
authorized_client[:validating,
:validator => { :a => { '$exists' => true } }].tap do |c|
c.create
@@ -2325,10 +2329,11 @@
end
end
end
describe '#parallel_scan', unless: sharded? do
+ max_server_version '4.0'
let(:documents) do
(1..200).map do |i|
{ name: "testing-scan-#{i}" }
end
@@ -2421,11 +2426,12 @@
end
it_behaves_like 'an operation supporting causally consistent reads'
end
- context 'when a read concern is provided', if: find_command_enabled? do
+ context 'when a read concern is provided' do
+ min_server_version '3.2'
let(:result) do
authorized_collection.with(options).parallel_scan(2)
end
@@ -2613,11 +2619,12 @@
result
}.to raise_exception(Mongo::Error::OperationFailure)
end
end
- context 'when collection has a validator', if: find_command_enabled? do
+ context 'when collection has a validator' do
+ min_server_version '3.2'
around(:each) do |spec|
authorized_client[:validating,
:validator => { :a => { '$exists' => true } }].tap do |c|
c.create
@@ -3025,11 +3032,12 @@
result
}.to raise_exception(Mongo::Error::OperationFailure)
end
end
- context 'when collection has a validator', if: find_command_enabled? do
+ context 'when collection has a validator' do
+ min_server_version '3.2'
around(:each) do |spec|
authorized_client[:validating,
:validator => { :a => { '$exists' => true } }].tap do |c|
c.create
@@ -3342,11 +3350,12 @@
result
}.to raise_exception(Mongo::Error::OperationFailure)
end
end
- context 'when collection has a validator', if: find_command_enabled? do
+ context 'when collection has a validator' do
+ min_server_version '3.2'
around(:each) do |spec|
authorized_client[:validating,
:validator => { :a => { '$exists' => true } }].tap do |c|
c.create
@@ -3779,21 +3788,23 @@
result
}.to raise_exception(Mongo::Error::OperationFailure)
end
end
- context 'when write_concern is provided', if: find_command_enabled? && standalone? do
+ context 'when write_concern is provided', if: standalone? do
+ min_server_version '3.2'
it 'uses the write concern' do
expect {
authorized_collection.find_one_and_delete(selector,
write_concern: { w: 2 })
}.to raise_error(Mongo::Error::OperationFailure)
end
end
- context 'when the collection has a write concern', if: find_command_enabled? && standalone? do
+ context 'when the collection has a write concern', if: standalone? do
+ min_server_version '3.2'
let(:collection) do
authorized_collection.with(write: { w: 2 })
end
@@ -4047,11 +4058,12 @@
result
}.to raise_exception(Mongo::Error::OperationFailure)
end
end
- context 'when collection has a validator', if: find_command_enabled? do
+ context 'when collection has a validator' do
+ min_server_version '3.2'
around(:each) do |spec|
authorized_client[:validating,
:validator => { :a => { '$exists' => true } }].tap do |c|
c.create
@@ -4106,22 +4118,24 @@
end
end
end
end
- context 'when write_concern is provided', if: find_command_enabled? && standalone? do
+ context 'when write_concern is provided', if: standalone? do
+ min_server_version '3.2'
it 'uses the write concern' do
expect {
authorized_collection.find_one_and_update(selector,
{ '$set' => { field: 'testing' }},
write_concern: { w: 2 })
}.to raise_error(Mongo::Error::OperationFailure)
end
end
- context 'when the collection has a write concern', if: find_command_enabled? && standalone? do
+ context 'when the collection has a write concern', if: standalone? do
+ min_server_version '3.2'
let(:collection) do
authorized_collection.with(write: { w: 2 })
end
@@ -4432,11 +4446,12 @@
result
}.to raise_exception(Mongo::Error::OperationFailure)
end
end
- context 'when collection has a validator', if: find_command_enabled? do
+ context 'when collection has a validator' do
+ min_server_version '3.2'
around(:each) do |spec|
authorized_client[:validating,
:validator => { :a => { '$exists' => true } }].tap do |c|
c.create
@@ -4491,21 +4506,23 @@
end
end
end
end
- context 'when write_concern is provided', if: find_command_enabled? && standalone? do
+ context 'when write_concern is provided', if: standalone? do
+ min_server_version '3.2'
it 'uses the write concern' do
expect {
authorized_collection.find_one_and_replace(selector,
{ field: 'testing' },
write_concern: { w: 2 })
}.to raise_error(Mongo::Error::OperationFailure)
end
end
- context 'when the collection has a write concern', if: find_command_enabled? && standalone? do
+ context 'when the collection has a write concern', if: standalone? do
+ min_server_version '3.2'
let(:collection) do
authorized_collection.with(write: { w: 2 })
end