File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ def create
84
84
# Drop the collection. Will also drop all indexes associated with the
85
85
# collection.
86
86
#
87
+ # @note An error returned if the collection doesn't exist is suppressed.
88
+ #
87
89
# @example Drop the collection.
88
90
# collection.drop
89
91
#
@@ -92,6 +94,9 @@ def create
92
94
# @since 2.0.0
93
95
def drop
94
96
database . command ( :drop => name )
97
+ rescue Error ::OperationFailure => ex
98
+ raise ex unless ex . message =~ /ns not found/
99
+ false
95
100
end
96
101
97
102
# Find documents in the collection.
Original file line number Diff line number Diff line change 229
229
it 'drops the collection from the database' do
230
230
expect ( database . collection_names ) . to_not include ( 'specs' )
231
231
end
232
+
233
+ context 'when the collection does not exist' do
234
+
235
+ it 'does not raise an error' do
236
+ expect ( database [ 'non-existent-coll' ] . drop ) . to be ( false )
237
+ end
238
+ end
232
239
end
233
240
234
241
describe '#find' do
You can’t perform that action at this time.
0 commit comments