mongo 2.0.0.rc → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -1
- data/README.md +1 -4
- data/lib/mongo/client.rb +1 -1
- data/lib/mongo/collection.rb +1 -1
- data/lib/mongo/collection/view.rb +1 -1
- data/lib/mongo/collection/view/writable.rb +26 -10
- data/lib/mongo/database.rb +1 -1
- data/lib/mongo/grid/file.rb +12 -0
- data/lib/mongo/grid/file/chunk.rb +1 -1
- data/lib/mongo/grid/file/metadata.rb +13 -0
- data/lib/mongo/operation/aggregate.rb +1 -1
- data/lib/mongo/operation/write.rb +1 -5
- data/lib/mongo/operation/write/bulk.rb +17 -0
- data/lib/mongo/operation/write/{bulk_delete.rb → bulk/bulk_delete.rb} +1 -1
- data/lib/mongo/operation/{bulk_delete → write/bulk/bulk_delete}/result.rb +3 -0
- data/lib/mongo/operation/write/{bulk_insert.rb → bulk/bulk_insert.rb} +1 -1
- data/lib/mongo/operation/{bulk_insert → write/bulk/bulk_insert}/result.rb +3 -0
- data/lib/mongo/operation/write/{bulk_mergable.rb → bulk/bulk_mergable.rb} +0 -0
- data/lib/mongo/operation/write/{bulk_update.rb → bulk/bulk_update.rb} +1 -1
- data/lib/mongo/operation/{bulk_update → write/bulk/bulk_update}/result.rb +8 -1
- data/lib/mongo/operation/write/{legacy_bulk_mergable.rb → bulk/legacy_bulk_mergable.rb} +0 -0
- data/lib/mongo/operation/write/delete.rb +2 -0
- data/lib/mongo/operation/write/delete/result.rb +40 -0
- data/lib/mongo/operation/write/insert.rb +2 -0
- data/lib/mongo/operation/write/insert/result.rb +32 -0
- data/lib/mongo/operation/write/update.rb +9 -4
- data/lib/mongo/operation/write/update/result.rb +160 -0
- data/lib/mongo/server/connectable.rb +11 -0
- data/lib/mongo/server/connection.rb +1 -0
- data/lib/mongo/server/connection_pool.rb +1 -1
- data/lib/mongo/server/connection_pool/queue.rb +1 -1
- data/lib/mongo/server/monitor.rb +16 -0
- data/lib/mongo/server/monitor/connection.rb +1 -0
- data/lib/mongo/socket/ssl.rb +30 -8
- data/lib/mongo/version.rb +1 -1
- data/lib/mongo/write_concern/acknowledged.rb +1 -1
- data/lib/mongo/write_concern/unacknowledged.rb +1 -1
- data/spec/certificates/ca.pem +17 -0
- data/spec/certificates/client.pem +101 -0
- data/spec/certificates/crl.pem +10 -0
- data/spec/certificates/crl_client_revoked.pem +12 -0
- data/spec/certificates/password_protected.pem +51 -0
- data/spec/certificates/server.pem +34 -0
- data/spec/mongo/collection/view/writable_spec.rb +175 -0
- data/spec/mongo/crud_spec.rb +42 -0
- data/spec/mongo/grid/file/metadata_spec.rb +23 -0
- data/spec/mongo/grid/file_spec.rb +34 -0
- data/spec/mongo/operation/write/delete_spec.rb +8 -0
- data/spec/mongo/operation/write/insert_spec.rb +21 -8
- data/spec/mongo/operation/write/update_spec.rb +52 -1
- data/spec/mongo/server/connection_spec.rb +33 -10
- data/spec/mongo/server/monitor_spec.rb +14 -0
- data/spec/spec_helper.rb +2 -17
- data/spec/support/crud.rb +203 -0
- data/spec/support/crud/read.rb +144 -0
- data/spec/support/crud/write.rb +214 -0
- data/spec/support/crud_tests/read/aggregate.yml +43 -0
- data/spec/support/crud_tests/read/count.yml +37 -0
- data/spec/support/crud_tests/read/distinct.yml +33 -0
- data/spec/support/crud_tests/read/find.yml +50 -0
- data/spec/support/crud_tests/write/deleteMany.yml +36 -0
- data/spec/support/crud_tests/write/deleteOne.yml +49 -0
- data/spec/support/crud_tests/write/findOneAndDelete.yml +54 -0
- data/spec/support/crud_tests/write/findOneAndReplace.yml +153 -0
- data/spec/support/crud_tests/write/findOneAndUpdate.yml +161 -0
- data/spec/support/crud_tests/write/insertMany.yml +24 -0
- data/spec/support/crud_tests/write/insertOne.yml +19 -0
- data/spec/support/crud_tests/write/replaceOne.yml +96 -0
- data/spec/support/crud_tests/write/updateMany.yml +83 -0
- data/spec/support/crud_tests/write/updateOne.yml +80 -0
- metadata +64 -20
- metadata.gz.sig +0 -0
- data/spec/mongo_orchestration_spec.rb +0 -70
- data/spec/support/mongo_orchestration.rb +0 -61
- data/spec/support/mongo_orchestration/requestable.rb +0 -109
- data/spec/support/mongo_orchestration/standalone.rb +0 -57
@@ -0,0 +1,10 @@
|
|
1
|
+
-----BEGIN X509 CRL-----
|
2
|
+
MIIBazCB1QIBATANBgkqhkiG9w0BAQUFADCBkjELMAkGA1UEBhMCVVMxETAPBgNV
|
3
|
+
BAgMCE5ldyBZb3JrMRYwFAYDVQQHDA1OZXcgWW9yayBDaXR5MQ4wDAYDVQQKDAUx
|
4
|
+
MEdlbjEPMA0GA1UECwwGS2VybmVsMRowGAYDVQQDDBFNeSBDZXJ0IEF1dGhvcml0
|
5
|
+
eTEbMBkGCSqGSIb3DQEJARYMcm9vdEBsYXphcnVzFw0xMjEyMTIxODQ3NDFaFw00
|
6
|
+
MDA0MjgxODQ3NDFaoA4wDDAKBgNVHRQEAwIBCzANBgkqhkiG9w0BAQUFAAOBgQAu
|
7
|
+
PlPDGei2q6kdkoHe8vmDuts7Hm/o9LFbBmn0XUcfHisCJCPsJTyGCsgnfIiBcXJY
|
8
|
+
1LMKsQFnYGv28rE2ZPpFg2qNxL+6qUEzCvqaHLX9q1V0F+f8hHDxucNYu52oo/h0
|
9
|
+
uNZxB1KPFI2PReG5d3oUYqJ2+EctKkrGtxSPzbN0gg==
|
10
|
+
-----END X509 CRL-----
|
@@ -0,0 +1,12 @@
|
|
1
|
+
-----BEGIN X509 CRL-----
|
2
|
+
MIIBujCCASMCAQEwDQYJKoZIhvcNAQEFBQAwgZIxCzAJBgNVBAYTAlVTMREwDwYD
|
3
|
+
VQQIDAhOZXcgWW9yazEWMBQGA1UEBwwNTmV3IFlvcmsgQ2l0eTEOMAwGA1UECgwF
|
4
|
+
MTBHZW4xDzANBgNVBAsMBktlcm5lbDEaMBgGA1UEAwwRTXkgQ2VydCBBdXRob3Jp
|
5
|
+
dHkxGzAZBgkqhkiG9w0BCQEWDHJvb3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MAkGA1UEBhMCVVMxETAPBgNVBAgMCE5l
|
23
|
+
dyBZb3JrMRYwFAYDVQQHDA1OZXcgWW9yayBDaXR5MQ4wDAYDVQQKDAUxMEdlbjEP
|
24
|
+
MA0GA1UECwwGS2VybmVsMQ8wDQYDVQQDDAZzZXJ2ZXIwgZ8wDQYJKoZIhvcNAQEB
|
25
|
+
BQADgY0AMIGJAoGBAK53miP9GczBWXnqNxHwQkgVqsDuesjwJbWilMK4gf3fjnf2
|
26
|
+
PN3qDpnGbZbPD0ij8975pIKtSPoDycFmA8Mogip0yU2Lv2lL56CWthSBftOFDL2C
|
27
|
+
WIsmuuURFXZPiVLtLytfI9oLASZFlywWCs83qEDTvdW8VoVhVsxV1JFDnpXLAgMB
|
28
|
+
AAGjezB5MAkGA1UdEwQCMAAwLAYJYIZIAYb4QgENBB8WHU9wZW5TU0wgR2VuZXJh
|
29
|
+
dGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBQgCkKiZhUV9/Zo7RwYYwm2cNK6tzAf
|
30
|
+
BgNVHSMEGDAWgBQHQRk6n37FtyJOt7zV3+T8CbhkFjANBgkqhkiG9w0BAQUFAAOB
|
31
|
+
gQCbsfr+Q4pty4Fy38lSxoCgnbB4pX6+Ex3xyw5zxDYR3xUlb/uHBiNZ1dBrXBxU
|
32
|
+
ekU8dEvf+hx4iRDSW/C5N6BGnBBhCHcrPabo2bEEWKVsbUC3xchTB5rNGkvnMt9t
|
33
|
+
G9ol7vanuzjL3S8/2PB33OshkBH570CxqqPflQbdjwt9dg==
|
34
|
+
-----END CERTIFICATE-----
|
@@ -392,6 +392,63 @@ describe Mongo::Collection::View::Writable do
|
|
392
392
|
expect(updated[:field]).to eq('testing')
|
393
393
|
end
|
394
394
|
end
|
395
|
+
|
396
|
+
context 'when upsert is false' do
|
397
|
+
|
398
|
+
let!(:response) do
|
399
|
+
view.replace_one({ field: 'test1' }, upsert: false)
|
400
|
+
end
|
401
|
+
|
402
|
+
let(:updated) do
|
403
|
+
authorized_collection.find(field: 'test1').to_a
|
404
|
+
end
|
405
|
+
|
406
|
+
it 'reports that no documents were written' do
|
407
|
+
expect(response.written_count).to eq(0)
|
408
|
+
end
|
409
|
+
|
410
|
+
it 'does not insert the document' do
|
411
|
+
expect(updated).to be_empty
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
415
|
+
context 'when upsert is true' do
|
416
|
+
|
417
|
+
let!(:response) do
|
418
|
+
view.replace_one({ field: 'test1' }, upsert: true)
|
419
|
+
end
|
420
|
+
|
421
|
+
let(:updated) do
|
422
|
+
authorized_collection.find(field: 'test1').first
|
423
|
+
end
|
424
|
+
|
425
|
+
it 'reports that a document was written' do
|
426
|
+
expect(response.written_count).to eq(1)
|
427
|
+
end
|
428
|
+
|
429
|
+
it 'inserts the document' do
|
430
|
+
expect(updated[:field]).to eq('test1')
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
context 'when upsert is not specified' do
|
435
|
+
|
436
|
+
let!(:response) do
|
437
|
+
view.replace_one({ field: 'test1' })
|
438
|
+
end
|
439
|
+
|
440
|
+
let(:updated) do
|
441
|
+
authorized_collection.find(field: 'test1').to_a
|
442
|
+
end
|
443
|
+
|
444
|
+
it 'reports that no documents were written' do
|
445
|
+
expect(response.written_count).to eq(0)
|
446
|
+
end
|
447
|
+
|
448
|
+
it 'does not insert the document' do
|
449
|
+
expect(updated).to be_empty
|
450
|
+
end
|
451
|
+
end
|
395
452
|
end
|
396
453
|
|
397
454
|
describe '#update_many' do
|
@@ -447,6 +504,65 @@ describe Mongo::Collection::View::Writable do
|
|
447
504
|
end
|
448
505
|
end
|
449
506
|
end
|
507
|
+
|
508
|
+
context 'when upsert is false' do
|
509
|
+
|
510
|
+
let(:response) do
|
511
|
+
view.update_many({ '$set'=> { field: 'testing' } },
|
512
|
+
upsert: false)
|
513
|
+
end
|
514
|
+
|
515
|
+
let(:updated) do
|
516
|
+
authorized_collection.find.to_a
|
517
|
+
end
|
518
|
+
|
519
|
+
it 'reports that no documents were updated' do
|
520
|
+
expect(response.written_count).to eq(0)
|
521
|
+
end
|
522
|
+
|
523
|
+
it 'updates no documents in the collection' do
|
524
|
+
expect(updated).to be_empty
|
525
|
+
end
|
526
|
+
end
|
527
|
+
|
528
|
+
context 'when upsert is true' do
|
529
|
+
|
530
|
+
let!(:response) do
|
531
|
+
view.update_many({ '$set'=> { field: 'testing' } },
|
532
|
+
upsert: true)
|
533
|
+
end
|
534
|
+
|
535
|
+
let(:updated) do
|
536
|
+
authorized_collection.find.first
|
537
|
+
end
|
538
|
+
|
539
|
+
it 'reports that a document was written' do
|
540
|
+
expect(response.written_count).to eq(1)
|
541
|
+
end
|
542
|
+
|
543
|
+
it 'inserts a document into the collection' do
|
544
|
+
expect(updated[:field]).to eq('testing')
|
545
|
+
end
|
546
|
+
end
|
547
|
+
|
548
|
+
context 'when upsert is not specified' do
|
549
|
+
|
550
|
+
let(:response) do
|
551
|
+
view.update_many({ '$set'=> { field: 'testing' } })
|
552
|
+
end
|
553
|
+
|
554
|
+
let(:updated) do
|
555
|
+
authorized_collection.find.to_a
|
556
|
+
end
|
557
|
+
|
558
|
+
it 'reports that no documents were updated' do
|
559
|
+
expect(response.written_count).to eq(0)
|
560
|
+
end
|
561
|
+
|
562
|
+
it 'updates no documents in the collection' do
|
563
|
+
expect(updated).to be_empty
|
564
|
+
end
|
565
|
+
end
|
450
566
|
end
|
451
567
|
|
452
568
|
describe '#update_one' do
|
@@ -500,5 +616,64 @@ describe Mongo::Collection::View::Writable do
|
|
500
616
|
expect(updated[:field]).to eq('testing')
|
501
617
|
end
|
502
618
|
end
|
619
|
+
|
620
|
+
context 'when upsert is false' do
|
621
|
+
|
622
|
+
let(:response) do
|
623
|
+
view.update_one({ '$set'=> { field: 'testing' } },
|
624
|
+
upsert: false)
|
625
|
+
end
|
626
|
+
|
627
|
+
let(:updated) do
|
628
|
+
authorized_collection.find.to_a
|
629
|
+
end
|
630
|
+
|
631
|
+
it 'reports that no documents were updated' do
|
632
|
+
expect(response.written_count).to eq(0)
|
633
|
+
end
|
634
|
+
|
635
|
+
it 'updates no documents in the collection' do
|
636
|
+
expect(updated).to be_empty
|
637
|
+
end
|
638
|
+
end
|
639
|
+
|
640
|
+
context 'when upsert is true' do
|
641
|
+
|
642
|
+
let!(:response) do
|
643
|
+
view.update_one({ '$set'=> { field: 'testing' } },
|
644
|
+
upsert: true)
|
645
|
+
end
|
646
|
+
|
647
|
+
let(:updated) do
|
648
|
+
authorized_collection.find.first
|
649
|
+
end
|
650
|
+
|
651
|
+
it 'reports that a document was written' do
|
652
|
+
expect(response.written_count).to eq(1)
|
653
|
+
end
|
654
|
+
|
655
|
+
it 'inserts a document into the collection' do
|
656
|
+
expect(updated[:field]).to eq('testing')
|
657
|
+
end
|
658
|
+
end
|
659
|
+
|
660
|
+
context 'when upsert is not specified' do
|
661
|
+
|
662
|
+
let(:response) do
|
663
|
+
view.update_one({ '$set'=> { field: 'testing' } })
|
664
|
+
end
|
665
|
+
|
666
|
+
let(:updated) do
|
667
|
+
authorized_collection.find.to_a
|
668
|
+
end
|
669
|
+
|
670
|
+
it 'reports that no documents were updated' do
|
671
|
+
expect(response.written_count).to eq(0)
|
672
|
+
end
|
673
|
+
|
674
|
+
it 'updates no documents in the collection' do
|
675
|
+
expect(updated).to be_empty
|
676
|
+
end
|
677
|
+
end
|
503
678
|
end
|
504
679
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'CRUD' do
|
4
|
+
|
5
|
+
CRUD_TESTS.each do |file|
|
6
|
+
|
7
|
+
spec = Mongo::CRUD::Spec.new(file)
|
8
|
+
|
9
|
+
context(spec.description) do
|
10
|
+
|
11
|
+
spec.tests.each do |test|
|
12
|
+
|
13
|
+
context(test.description) do
|
14
|
+
|
15
|
+
before(:each) do
|
16
|
+
authorized_collection.find.delete_many
|
17
|
+
end
|
18
|
+
|
19
|
+
after(:each) do
|
20
|
+
authorized_collection.find.delete_many
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:results) do
|
24
|
+
test.run(authorized_collection)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns the correct result" do
|
28
|
+
skip 'Test results only match with server version >= 2.6' if test.requires_2_6?(write_command_enabled?,
|
29
|
+
authorized_collection)
|
30
|
+
expect(results).to eq(test.result)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'has the correct data in the collection' do
|
34
|
+
skip 'Test results only match with server version >= 2.6' if test.requires_2_6?(write_command_enabled?,
|
35
|
+
authorized_collection)
|
36
|
+
expect(test.run(authorized_collection)).to match_collection_data(test)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -66,4 +66,27 @@ describe Mongo::Grid::File::Metadata do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
|
+
|
70
|
+
describe '#inspect' do
|
71
|
+
|
72
|
+
let(:metadata) do
|
73
|
+
described_class.new(:filename => 'test.txt', :length => 7)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'includes the chunk size' do
|
77
|
+
expect(metadata.inspect).to include(metadata.chunk_size.to_s)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'includes the filename' do
|
81
|
+
expect(metadata.inspect).to include(metadata.filename)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'includes the md5' do
|
85
|
+
expect(metadata.inspect).to include(metadata.md5.to_s)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'includes the id' do
|
89
|
+
expect(metadata.inspect).to include(metadata.id.to_s)
|
90
|
+
end
|
91
|
+
end
|
69
92
|
end
|
@@ -66,6 +66,29 @@ describe Mongo::Grid::File do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
context 'when data is a ruby file' do
|
70
|
+
|
71
|
+
let(:ruby_file) do
|
72
|
+
File.open(__FILE__)
|
73
|
+
end
|
74
|
+
|
75
|
+
let(:data) do
|
76
|
+
ruby_file.read
|
77
|
+
end
|
78
|
+
|
79
|
+
let(:file) do
|
80
|
+
described_class.new(data, :filename => File.basename(ruby_file.path))
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'sets the data' do
|
84
|
+
expect(file.data).to eq(data)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'creates the chunks' do
|
88
|
+
expect(file.chunks.size).to eq(4)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
69
92
|
context 'when using idiomatic ruby field names' do
|
70
93
|
|
71
94
|
let(:time) do
|
@@ -135,4 +158,15 @@ describe Mongo::Grid::File do
|
|
135
158
|
end
|
136
159
|
end
|
137
160
|
end
|
161
|
+
|
162
|
+
describe '#inspect' do
|
163
|
+
|
164
|
+
let(:file) do
|
165
|
+
described_class.new('Hi', :filename => 'test.txt')
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'includes the filename' do
|
169
|
+
expect(file.inspect).to include('test.txt')
|
170
|
+
end
|
171
|
+
end
|
138
172
|
end
|
@@ -99,6 +99,10 @@ describe Mongo::Operation::Write::Delete do
|
|
99
99
|
it 'deletes the documents from the database' do
|
100
100
|
expect(result.written_count).to eq(1)
|
101
101
|
end
|
102
|
+
|
103
|
+
it 'reports the correct deleted count' do
|
104
|
+
expect(result.deleted_count).to eq(1)
|
105
|
+
end
|
102
106
|
end
|
103
107
|
|
104
108
|
context 'when the delete fails' do
|
@@ -139,6 +143,10 @@ describe Mongo::Operation::Write::Delete do
|
|
139
143
|
it 'deletes the documents from the database' do
|
140
144
|
expect(result.written_count).to eq(2)
|
141
145
|
end
|
146
|
+
|
147
|
+
it 'reports the correct deleted count' do
|
148
|
+
expect(result.deleted_count).to eq(2)
|
149
|
+
end
|
142
150
|
end
|
143
151
|
|
144
152
|
context 'when a delete fails' do
|
@@ -3,7 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe Mongo::Operation::Write::Insert do
|
4
4
|
|
5
5
|
let(:documents) do
|
6
|
-
[{
|
6
|
+
[{ '_id' => 1,
|
7
|
+
'name' => 'test' }]
|
7
8
|
end
|
8
9
|
|
9
10
|
let(:spec) do
|
@@ -94,17 +95,21 @@ describe Mongo::Operation::Write::Insert do
|
|
94
95
|
|
95
96
|
context 'when the insert succeeds' do
|
96
97
|
|
97
|
-
let(:response) do
|
98
|
+
let!(:response) do
|
98
99
|
insert.execute(authorized_primary.context)
|
99
100
|
end
|
100
101
|
|
101
|
-
it '
|
102
|
+
it 'reports the correct written count', if: write_command_enabled? do
|
102
103
|
expect(response.written_count).to eq(1)
|
103
104
|
end
|
104
105
|
|
105
|
-
it '
|
106
|
+
it 'reports the correct written count', unless: write_command_enabled? do
|
106
107
|
expect(response.written_count).to eq(0)
|
107
108
|
end
|
109
|
+
|
110
|
+
it 'inserts the document into the collection' do
|
111
|
+
expect(authorized_collection.find(_id: 1).to_a). to eq(documents)
|
112
|
+
end
|
108
113
|
end
|
109
114
|
|
110
115
|
context 'when the insert fails' do
|
@@ -139,20 +144,27 @@ describe Mongo::Operation::Write::Insert do
|
|
139
144
|
context 'when the insert succeeds' do
|
140
145
|
|
141
146
|
let(:documents) do
|
142
|
-
[{
|
147
|
+
[{ '_id' => 1,
|
148
|
+
'name' => 'test1' },
|
149
|
+
{ '_id' => 2,
|
150
|
+
'name' => 'test2' }]
|
143
151
|
end
|
144
152
|
|
145
|
-
let(:response) do
|
153
|
+
let!(:response) do
|
146
154
|
insert.execute(authorized_primary.context)
|
147
155
|
end
|
148
156
|
|
149
|
-
it '
|
157
|
+
it 'reports the correct written count', if: write_command_enabled? do
|
150
158
|
expect(response.written_count).to eq(2)
|
151
159
|
end
|
152
160
|
|
153
|
-
it '
|
161
|
+
it 'reports the correct written count', unless: write_command_enabled? do
|
154
162
|
expect(response.written_count).to eq(0)
|
155
163
|
end
|
164
|
+
|
165
|
+
it 'inserts the documents into the collection' do
|
166
|
+
expect(authorized_collection.find.to_a). to eq(documents)
|
167
|
+
end
|
156
168
|
end
|
157
169
|
|
158
170
|
context 'when the insert fails on the last document' do
|
@@ -205,6 +217,7 @@ describe Mongo::Operation::Write::Insert do
|
|
205
217
|
failing_insert.execute(authorized_primary.context)
|
206
218
|
}.to raise_error(Mongo::Error::OperationFailure)
|
207
219
|
end
|
220
|
+
|
208
221
|
end
|
209
222
|
|
210
223
|
context 'when a document exceeds max bson size' do
|