spec/mongo/operation/delete_spec.rb in mongo-2.6.4 vs spec/mongo/operation/delete_spec.rb in mongo-2.7.0.rc0
- old
+ new
@@ -1,21 +1,31 @@
require 'spec_helper'
describe Mongo::Operation::Delete do
+ before do
+ begin
+ authorized_collection.delete_many
+ rescue Mongo::Error::OperationFailure
+ end
+ begin
+ authorized_collection.indexes.drop_all
+ rescue Mongo::Error::OperationFailure
+ end
+ end
let(:document) do
{
:q => { :foo => 1 },
:limit => 1
}
end
let(:spec) do
{ :deletes => [ document ],
- :db_name => TEST_DB,
+ :db_name => SpecConfig.instance.test_db,
:coll_name => TEST_COLL,
- :write_concern => Mongo::WriteConcern.get(WRITE_CONCERN),
+ :write_concern => Mongo::WriteConcern.get(SpecConfig.instance.write_concern),
:ordered => true
}
end
let(:op) { described_class.new(spec) }
@@ -45,13 +55,13 @@
context 'when two ops have different specs' do
let(:other_doc) { { :q => { :bar => 1 }, :limit => 1 } }
let(:other_spec) do
{ :deletes => [ other_doc ],
- :db_name => TEST_DB,
+ :db_name => SpecConfig.instance.test_db,
:coll_name => TEST_COLL,
- :write_concern => Mongo::WriteConcern.get(WRITE_CONCERN),
+ :write_concern => Mongo::WriteConcern.get(SpecConfig.instance.write_concern),
:ordered => true
}
end
let(:other) { described_class.new(other_spec) }
@@ -78,13 +88,13 @@
context 'when deleting a single document' do
let(:delete) do
described_class.new({
deletes: [ document ],
- db_name: TEST_DB,
+ db_name: SpecConfig.instance.test_db,
coll_name: TEST_COLL,
- write_concern: Mongo::WriteConcern.get(WRITE_CONCERN)
+ write_concern: Mongo::WriteConcern.get(SpecConfig.instance.write_concern)
})
end
context 'when the delete succeeds' do
@@ -122,13 +132,13 @@
context 'when deleting multiple documents' do
let(:delete) do
described_class.new({
deletes: [ document ],
- db_name: TEST_DB,
+ db_name: SpecConfig.instance.test_db,
coll_name: TEST_COLL,
- write_concern: Mongo::WriteConcern.get(WRITE_CONCERN)
+ write_concern: Mongo::WriteConcern.get(SpecConfig.instance.write_concern)
})
end
context 'when the deletes succeed' do
@@ -181,15 +191,16 @@
}.to raise_error(Mongo::Error::MaxBSONSize)
end
end
end
- context 'when write concern { w: 0 } is used', unless: op_msg_enabled? do
+ context 'when write concern { w: 0 } is used' do
+ max_server_version '3.4'
let(:delete) do
described_class.new({
deletes: [ document ],
- db_name: TEST_DB,
+ db_name: SpecConfig.instance.test_db,
coll_name: TEST_COLL,
write_concern: Mongo::WriteConcern.get(:w => 0)
})
end