File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 240
240
end
241
241
end
242
242
243
+ context 'when the message exceeds the max size' do
244
+
245
+ context 'when the message is an insert' do
246
+
247
+ before do
248
+ allow ( connection ) . to receive ( :max_message_size ) . and_return ( 200 )
249
+ end
250
+
251
+ let ( :documents ) do
252
+ [ { 'name' => 'testing' } ] * 10
253
+ end
254
+
255
+ let ( :reply ) do
256
+ connection . dispatch ( [ insert ] )
257
+ end
258
+
259
+ it 'checks the size against the max message size' do
260
+ expect {
261
+ reply
262
+ } . to raise_exception ( Mongo ::Error ::MaxMessageSize )
263
+ end
264
+ end
265
+
266
+ context 'when the message is a command' do
267
+
268
+ before do
269
+ allow ( connection ) . to receive ( :max_bson_object_size ) . and_return ( 100 )
270
+ end
271
+
272
+ let ( :selector ) do
273
+ { :getlasterror => '1' }
274
+ end
275
+
276
+ let ( :command ) do
277
+ Mongo ::Protocol ::Query . new ( TEST_DB , '$cmd' , selector , :limit => -1 )
278
+ end
279
+
280
+ let ( :reply ) do
281
+ connection . dispatch ( [ command ] )
282
+ end
283
+
284
+ it 'checks the size against the max bson size' do
285
+ expect {
286
+ reply
287
+ } . to raise_exception ( Mongo ::Error ::MaxBSONSize )
288
+ end
289
+ end
290
+ end
291
+
243
292
context 'when a network or socket error occurs' do
244
293
245
294
let ( :socket ) do
You can’t perform that action at this time.
0 commit comments