spec/mongo/collection_spec.rb in mongo-2.4.0 vs spec/mongo/collection_spec.rb in mongo-2.4.1

- old
+ new

@@ -536,68 +536,77 @@ let(:collection) do described_class.new(database, :specs) end - before do - collection.create - end + context 'when the collection exists' do + before do + collection.create + end - context 'when the collection does not have a write concern set' do + context 'when the collection does not have a write concern set' do - let!(:response) do - collection.drop - end + let!(:response) do + collection.drop + end - it 'executes the command' do - expect(response).to be_successful - end + it 'executes the command' do + expect(response).to be_successful + end - it 'drops the collection from the database' do - expect(database.collection_names).to_not include('specs') - end + it 'drops the collection from the database' do + expect(database.collection_names).to_not include('specs') + end - context 'when the collection does not exist' do + context 'when the collection does not exist' do - it 'does not raise an error' do - expect(database['non-existent-coll'].drop).to be(false) + it 'does not raise an error' do + expect(database['non-existent-coll'].drop).to be(false) + end end end - end - context 'when the collection has a write concern' do + context 'when the collection has a write concern' do - let(:write_options) do - { - write: { w: WRITE_CONCERN[:w] + 1} - } - end + let(:write_options) do + { + write: { w: WRITE_CONCERN[:w] + 1} + } + end - let(:collection_with_write_options) do - collection.with(write_options) - end + let(:collection_with_write_options) do + collection.with(write_options) + end - after do - collection.drop - end + after do + collection.drop + end - context 'when the server supports write concern on the drop command', if: collation_enabled? do + context 'when the server supports write concern on the drop command', if: collation_enabled? do - it 'applies the write concern' do - expect{ - collection_with_write_options.drop - }.to raise_exception(Mongo::Error::OperationFailure) + it 'applies the write concern' do + expect{ + collection_with_write_options.drop + }.to raise_exception(Mongo::Error::OperationFailure) + end end - end - context 'when the server does not support write concern on the drop command', unless: collation_enabled? do + context 'when the server does not support write concern on the drop command', unless: collation_enabled? do - it 'does not apply the write concern' do - expect(collection_with_write_options.drop).to be_successful + it 'does not apply the write concern' do + expect(collection_with_write_options.drop).to be_successful + end end end end + + context 'when the collection does not exist' do + + it 'returns false' do + expect(collection.drop).to be(false) + end + end end describe '#find' do context 'when provided a filter' do @@ -1156,10 +1165,10 @@ let(:options) do { :allow_disk_use => true, :bypass_document_validation => true } end it 'sets the options on the Aggregation object' do - expect(authorized_collection.aggregate([], options).options).to eq(options) + expect(authorized_collection.aggregate([], options).options).to eq(BSON::Document.new(options)) end context 'when collation is provided' do before do