mongo 2.7.0 → 2.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.md +39 -14
  5. data/Rakefile +1 -0
  6. data/lib/mongo/auth.rb +4 -1
  7. data/lib/mongo/client.rb +4 -3
  8. data/lib/mongo/cluster.rb +1 -1
  9. data/lib/mongo/collection/view/readable.rb +5 -2
  10. data/lib/mongo/database.rb +1 -0
  11. data/lib/mongo/error/invalid_server_preference.rb +1 -0
  12. data/lib/mongo/error/operation_failure.rb +10 -0
  13. data/lib/mongo/error/parser.rb +10 -0
  14. data/lib/mongo/event.rb +1 -2
  15. data/lib/mongo/operation/result.rb +4 -1
  16. data/lib/mongo/operation/shared/executable_transaction_label.rb +3 -1
  17. data/lib/mongo/operation/shared/sessions_supported.rb +1 -1
  18. data/lib/mongo/protocol/msg.rb +1 -1
  19. data/lib/mongo/protocol/query.rb +2 -2
  20. data/lib/mongo/retryable.rb +20 -6
  21. data/lib/mongo/server.rb +6 -0
  22. data/lib/mongo/server/connection.rb +4 -4
  23. data/lib/mongo/server/monitor/connection.rb +9 -5
  24. data/lib/mongo/server_selector/selectable.rb +86 -32
  25. data/lib/mongo/session.rb +98 -15
  26. data/lib/mongo/version.rb +1 -1
  27. data/spec/README.md +85 -0
  28. data/spec/integration/bulk_insert_spec.rb +1 -1
  29. data/spec/integration/change_stream_examples_spec.rb +3 -1
  30. data/spec/integration/change_stream_spec.rb +10 -14
  31. data/spec/integration/client_construction_spec.rb +1 -0
  32. data/spec/integration/command_monitoring_spec.rb +37 -1
  33. data/spec/integration/command_spec.rb +141 -0
  34. data/spec/integration/connection_spec.rb +4 -2
  35. data/spec/integration/cursor_reaping_spec.rb +1 -1
  36. data/spec/integration/docs_examples_spec.rb +1 -1
  37. data/spec/integration/retryable_writes_spec.rb +33 -42
  38. data/spec/integration/server_description_spec.rb +3 -3
  39. data/spec/integration/server_selector_spec.rb +79 -0
  40. data/spec/lite_spec_helper.rb +4 -2
  41. data/spec/mongo/address_spec.rb +8 -0
  42. data/spec/mongo/auth/cr_spec.rb +5 -2
  43. data/spec/mongo/auth/invalid_mechanism_spec.rb +11 -0
  44. data/spec/mongo/auth/scram/conversation_spec.rb +3 -2
  45. data/spec/mongo/auth/scram/negotiation_spec.rb +1 -2
  46. data/spec/mongo/auth/scram_spec.rb +11 -6
  47. data/spec/mongo/auth/user/view_spec.rb +13 -6
  48. data/spec/mongo/bulk_write_spec.rb +81 -104
  49. data/spec/mongo/client_construction_spec.rb +18 -7
  50. data/spec/mongo/client_spec.rb +11 -7
  51. data/spec/mongo/cluster_spec.rb +30 -1
  52. data/spec/mongo/collection/view/aggregation_spec.rb +18 -10
  53. data/spec/mongo/collection/view/change_stream_spec.rb +28 -8
  54. data/spec/mongo/collection/view/map_reduce_spec.rb +24 -10
  55. data/spec/mongo/collection/view/readable_spec.rb +37 -19
  56. data/spec/mongo/collection/view/writable_spec.rb +64 -32
  57. data/spec/mongo/collection/view_spec.rb +4 -2
  58. data/spec/mongo/collection_spec.rb +163 -73
  59. data/spec/mongo/cursor_spec.rb +5 -2
  60. data/spec/mongo/database_spec.rb +41 -19
  61. data/spec/mongo/error/no_server_available_spec.rb +1 -1
  62. data/spec/mongo/error/parser_spec.rb +29 -0
  63. data/spec/mongo/grid/stream/write_spec.rb +2 -1
  64. data/spec/mongo/index/view_spec.rb +42 -24
  65. data/spec/mongo/operation/delete/op_msg_spec.rb +11 -7
  66. data/spec/mongo/operation/insert/op_msg_spec.rb +10 -6
  67. data/spec/mongo/operation/update/op_msg_spec.rb +10 -6
  68. data/spec/mongo/protocol/compressed_spec.rb +1 -1
  69. data/spec/mongo/protocol/msg_spec.rb +1 -1
  70. data/spec/mongo/server/app_metadata_spec.rb +2 -1
  71. data/spec/mongo/server/connection_auth_spec.rb +1 -1
  72. data/spec/mongo/server/monitor/connection_spec.rb +42 -0
  73. data/spec/mongo/server_selector_spec.rb +17 -0
  74. data/spec/mongo/server_spec.rb +110 -0
  75. data/spec/mongo/session/session_pool_spec.rb +1 -1
  76. data/spec/mongo/session_spec.rb +1 -1
  77. data/spec/mongo/session_transaction_spec.rb +162 -1
  78. data/spec/mongo/socket/ssl_spec.rb +14 -7
  79. data/spec/mongo/uri/srv_protocol_spec.rb +41 -34
  80. data/spec/spec_helper.rb +3 -191
  81. data/spec/spec_tests/change_streams_spec.rb +3 -6
  82. data/spec/spec_tests/data/transactions/abort.yml +3 -1
  83. data/spec/spec_tests/data/transactions/commit.yml +4 -3
  84. data/spec/spec_tests/data/transactions/error-labels.yml +17 -13
  85. data/spec/spec_tests/data/transactions/read-concern.yml +611 -0
  86. data/spec/spec_tests/data/transactions/retryable-commit.yml +126 -21
  87. data/spec/spec_tests/data/transactions_api/callback-aborts.yml +42 -39
  88. data/spec/spec_tests/data/transactions_api/callback-commits.yml +52 -50
  89. data/spec/spec_tests/data/transactions_api/callback-retry.yml +33 -31
  90. data/spec/spec_tests/data/transactions_api/commit-retry.yml +42 -39
  91. data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror-4.2.yml +13 -12
  92. data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror.yml +15 -26
  93. data/spec/spec_tests/data/transactions_api/commit-writeconcernerror.yml +25 -33
  94. data/spec/spec_tests/data/transactions_api/commit.yml +44 -42
  95. data/spec/spec_tests/data/transactions_api/transaction-options.yml +25 -23
  96. data/spec/spec_tests/max_staleness_spec.rb +2 -0
  97. data/spec/spec_tests/retryable_writes_spec.rb +2 -6
  98. data/spec/spec_tests/sdam_spec.rb +2 -0
  99. data/spec/spec_tests/server_selection_spec.rb +3 -0
  100. data/spec/spec_tests/transactions_api_spec.rb +7 -1
  101. data/spec/spec_tests/transactions_spec.rb +6 -0
  102. data/spec/spec_tests/uri_options_spec.rb +4 -26
  103. data/spec/support/certificates/ca.pem +21 -16
  104. data/spec/support/certificates/client.pem +90 -90
  105. data/spec/support/certificates/client_cert.pem +21 -20
  106. data/spec/support/certificates/client_key.pem +27 -28
  107. data/spec/support/certificates/client_key_encrypted.pem +26 -26
  108. data/spec/support/certificates/crl.pem +10 -8
  109. data/spec/support/certificates/crl_client_revoked.pem +11 -10
  110. data/spec/support/certificates/server.pem +48 -33
  111. data/spec/support/change_streams.rb +12 -32
  112. data/spec/support/client_registry.rb +12 -1
  113. data/spec/support/cluster_config.rb +48 -2
  114. data/spec/support/common_shortcuts.rb +73 -7
  115. data/spec/support/connection_string.rb +0 -3
  116. data/spec/support/constraints.rb +87 -22
  117. data/spec/support/crud.rb +2 -1
  118. data/spec/support/shared/server_selector.rb +0 -28
  119. data/spec/support/shared/session.rb +25 -14
  120. data/spec/support/transactions.rb +4 -8
  121. data/spec/support/transactions/operation.rb +26 -4
  122. data/spec/support/transactions/verifier.rb +5 -2
  123. metadata +496 -488
  124. metadata.gz.sig +5 -2
  125. data/spec/support/certificates/password_protected.pem +0 -51
@@ -94,14 +94,16 @@ describe Mongo::Collection::View::Writable do
94
94
  { collation: { locale: 'en_US', strength: 2 } }
95
95
  end
96
96
 
97
- context 'when the server selected supports collations', if: collation_enabled? do
97
+ context 'when the server selected supports collations' do
98
+ min_server_fcv '3.4'
98
99
 
99
100
  it 'applies the collation' do
100
101
  expect(result['name']).to eq('bang')
101
102
  end
102
103
  end
103
104
 
104
- context 'when the server selected does not support collations', unless: collation_enabled? do
105
+ context 'when the server selected does not support collations' do
106
+ max_server_version '3.2'
105
107
 
106
108
  it 'raises an exception' do
107
109
  expect {
@@ -161,14 +163,16 @@ describe Mongo::Collection::View::Writable do
161
163
  { collation: { locale: 'en_US', strength: 2 } }
162
164
  end
163
165
 
164
- context 'when the server selected supports collations', if: collation_enabled? do
166
+ context 'when the server selected supports collations' do
167
+ min_server_fcv '3.4'
165
168
 
166
169
  it 'applies the collation' do
167
170
  expect(result['name']).to eq('bang')
168
171
  end
169
172
  end
170
173
 
171
- context 'when the server selected does not support collations', unless: collation_enabled? do
174
+ context 'when the server selected does not support collations' do
175
+ max_server_version '3.2'
172
176
 
173
177
  it 'raises an exception' do
174
178
  expect {
@@ -287,7 +291,8 @@ describe Mongo::Collection::View::Writable do
287
291
  { collation: { locale: 'en_US', strength: 2 } }
288
292
  end
289
293
 
290
- context 'when the server selected supports collations', if: collation_enabled? do
294
+ context 'when the server selected supports collations' do
295
+ min_server_fcv '3.4'
291
296
 
292
297
  it 'applies the collation' do
293
298
  expect(result['name']).to eq('bang')
@@ -295,7 +300,8 @@ describe Mongo::Collection::View::Writable do
295
300
  end
296
301
  end
297
302
 
298
- context 'when the server selected does not support collations', unless: collation_enabled? do
303
+ context 'when the server selected does not support collations' do
304
+ max_server_version '3.2'
299
305
 
300
306
  it 'raises an exception' do
301
307
  expect {
@@ -336,7 +342,8 @@ describe Mongo::Collection::View::Writable do
336
342
  { collation: { locale: 'en_US', strength: 2 } }
337
343
  end
338
344
 
339
- context 'when the server selected supports collations', if: collation_enabled? do
345
+ context 'when the server selected supports collations' do
346
+ min_server_fcv '3.4'
340
347
 
341
348
  it 'applies the collation' do
342
349
  expect(result['name']).to eq('bang')
@@ -344,7 +351,8 @@ describe Mongo::Collection::View::Writable do
344
351
  end
345
352
  end
346
353
 
347
- context 'when the server selected does not support collations', unless: collation_enabled? do
354
+ context 'when the server selected does not support collations' do
355
+ max_server_version '3.2'
348
356
 
349
357
  it 'raises an exception' do
350
358
  expect {
@@ -497,7 +505,8 @@ describe Mongo::Collection::View::Writable do
497
505
  { collation: { locale: 'en_US', strength: 2 } }
498
506
  end
499
507
 
500
- context 'when the server selected supports collations', if: collation_enabled? do
508
+ context 'when the server selected supports collations' do
509
+ min_server_fcv '3.4'
501
510
 
502
511
  it 'applies the collation' do
503
512
  expect(result['name']).to eq('bang')
@@ -505,7 +514,8 @@ describe Mongo::Collection::View::Writable do
505
514
  end
506
515
  end
507
516
 
508
- context 'when the server selected does not support collations', unless: collation_enabled? do
517
+ context 'when the server selected does not support collations' do
518
+ max_server_version '3.2'
509
519
 
510
520
  it 'raises an exception' do
511
521
  expect {
@@ -546,7 +556,8 @@ describe Mongo::Collection::View::Writable do
546
556
  { collation: { locale: 'en_US', strength: 2 } }
547
557
  end
548
558
 
549
- context 'when the server selected supports collations', if: collation_enabled? do
559
+ context 'when the server selected supports collations' do
560
+ min_server_fcv '3.4'
550
561
 
551
562
  it 'applies the collation' do
552
563
  expect(result['name']).to eq('bang')
@@ -554,7 +565,8 @@ describe Mongo::Collection::View::Writable do
554
565
  end
555
566
  end
556
567
 
557
- context 'when the server selected does not support collations', unless: collation_enabled? do
568
+ context 'when the server selected does not support collations' do
569
+ max_server_version '3.2'
558
570
 
559
571
  it 'raises an exception' do
560
572
  expect {
@@ -667,7 +679,8 @@ describe Mongo::Collection::View::Writable do
667
679
  { collation: { locale: 'en_US', strength: 2 } }
668
680
  end
669
681
 
670
- context 'when the server selected supports collations', if: collation_enabled? do
682
+ context 'when the server selected supports collations' do
683
+ min_server_fcv '3.4'
671
684
 
672
685
  it 'applies the collation' do
673
686
  expect(result.written_count).to eq(2)
@@ -675,7 +688,8 @@ describe Mongo::Collection::View::Writable do
675
688
  end
676
689
  end
677
690
 
678
- context 'when the server selected does not support collations', unless: collation_enabled? do
691
+ context 'when the server selected does not support collations' do
692
+ max_server_version '3.2'
679
693
 
680
694
  it 'raises an exception' do
681
695
  expect {
@@ -717,7 +731,8 @@ describe Mongo::Collection::View::Writable do
717
731
  { collation: { locale: 'en_US', strength: 2 } }
718
732
  end
719
733
 
720
- context 'when the server selected supports collations', if: collation_enabled? do
734
+ context 'when the server selected supports collations' do
735
+ min_server_fcv '3.4'
721
736
 
722
737
  it 'applies the collation' do
723
738
  expect(result.written_count).to eq(2)
@@ -725,7 +740,8 @@ describe Mongo::Collection::View::Writable do
725
740
  end
726
741
  end
727
742
 
728
- context 'when the server selected does not support collations', unless: collation_enabled? do
743
+ context 'when the server selected does not support collations' do
744
+ max_server_version '3.2'
729
745
 
730
746
  it 'raises an exception' do
731
747
  expect {
@@ -828,7 +844,8 @@ describe Mongo::Collection::View::Writable do
828
844
  { collation: { locale: 'en_US', strength: 2 } }
829
845
  end
830
846
 
831
- context 'when the server selected supports collations', if: collation_enabled? do
847
+ context 'when the server selected supports collations' do
848
+ min_server_fcv '3.4'
832
849
 
833
850
  it 'applies the collation' do
834
851
  expect(result.written_count).to eq(1)
@@ -836,7 +853,8 @@ describe Mongo::Collection::View::Writable do
836
853
  end
837
854
  end
838
855
 
839
- context 'when the server selected does not support collations', unless: collation_enabled? do
856
+ context 'when the server selected does not support collations' do
857
+ max_server_version '3.2'
840
858
 
841
859
  it 'raises an exception' do
842
860
  expect {
@@ -877,7 +895,8 @@ describe Mongo::Collection::View::Writable do
877
895
  { collation: { locale: 'en_US', strength: 2 } }
878
896
  end
879
897
 
880
- context 'when the server selected supports collations', if: collation_enabled? do
898
+ context 'when the server selected supports collations' do
899
+ min_server_fcv '3.4'
881
900
 
882
901
  it 'applies the collation' do
883
902
  expect(result.written_count).to eq(1)
@@ -885,7 +904,8 @@ describe Mongo::Collection::View::Writable do
885
904
  end
886
905
  end
887
906
 
888
- context 'when the server selected does not support collations', unless: collation_enabled? do
907
+ context 'when the server selected does not support collations' do
908
+ max_server_version '3.2'
889
909
 
890
910
  it 'raises an exception' do
891
911
  expect {
@@ -1056,7 +1076,8 @@ describe Mongo::Collection::View::Writable do
1056
1076
  { collation: { locale: 'en_US', strength: 2 } }
1057
1077
  end
1058
1078
 
1059
- context 'when the server selected supports collations', if: collation_enabled? do
1079
+ context 'when the server selected supports collations' do
1080
+ min_server_fcv '3.4'
1060
1081
 
1061
1082
  it 'applies the collation' do
1062
1083
  expect(result.written_count).to eq(1)
@@ -1064,7 +1085,8 @@ describe Mongo::Collection::View::Writable do
1064
1085
  end
1065
1086
  end
1066
1087
 
1067
- context 'when the server selected does not support collations', unless: collation_enabled? do
1088
+ context 'when the server selected does not support collations' do
1089
+ max_server_version '3.2'
1068
1090
 
1069
1091
  it 'raises an exception' do
1070
1092
  expect {
@@ -1105,7 +1127,8 @@ describe Mongo::Collection::View::Writable do
1105
1127
  { collation: { locale: 'en_US', strength: 2 } }
1106
1128
  end
1107
1129
 
1108
- context 'when the server selected supports collations', if: collation_enabled? do
1130
+ context 'when the server selected supports collations' do
1131
+ min_server_fcv '3.4'
1109
1132
 
1110
1133
  it 'applies the collation' do
1111
1134
  expect(result.written_count).to eq(1)
@@ -1113,7 +1136,8 @@ describe Mongo::Collection::View::Writable do
1113
1136
  end
1114
1137
  end
1115
1138
 
1116
- context 'when the server selected does not support collations', unless: collation_enabled? do
1139
+ context 'when the server selected does not support collations' do
1140
+ max_server_version '3.2'
1117
1141
 
1118
1142
  it 'raises an exception' do
1119
1143
  expect {
@@ -1289,7 +1313,8 @@ describe Mongo::Collection::View::Writable do
1289
1313
  { collation: { locale: 'en_US', strength: 2 } }
1290
1314
  end
1291
1315
 
1292
- context 'when the server selected supports collations', if: collation_enabled? do
1316
+ context 'when the server selected supports collations' do
1317
+ min_server_fcv '3.4'
1293
1318
 
1294
1319
  it 'applies the collation' do
1295
1320
  expect(result.written_count).to eq(2)
@@ -1297,7 +1322,8 @@ describe Mongo::Collection::View::Writable do
1297
1322
  end
1298
1323
  end
1299
1324
 
1300
- context 'when the server selected does not support collations', unless: collation_enabled? do
1325
+ context 'when the server selected does not support collations' do
1326
+ max_server_version '3.2'
1301
1327
 
1302
1328
  it 'raises an exception' do
1303
1329
  expect {
@@ -1339,7 +1365,8 @@ describe Mongo::Collection::View::Writable do
1339
1365
  { collation: { locale: 'en_US', strength: 2 } }
1340
1366
  end
1341
1367
 
1342
- context 'when the server selected supports collations', if: collation_enabled? do
1368
+ context 'when the server selected supports collations' do
1369
+ min_server_fcv '3.4'
1343
1370
 
1344
1371
  it 'applies the collation' do
1345
1372
  expect(result.written_count).to eq(2)
@@ -1347,7 +1374,8 @@ describe Mongo::Collection::View::Writable do
1347
1374
  end
1348
1375
  end
1349
1376
 
1350
- context 'when the server selected does not support collations', unless: collation_enabled? do
1377
+ context 'when the server selected does not support collations' do
1378
+ max_server_version '3.2'
1351
1379
 
1352
1380
  it 'raises an exception' do
1353
1381
  expect {
@@ -1520,7 +1548,8 @@ describe Mongo::Collection::View::Writable do
1520
1548
  { collation: { locale: 'en_US', strength: 2 } }
1521
1549
  end
1522
1550
 
1523
- context 'when the server selected supports collations', if: collation_enabled? do
1551
+ context 'when the server selected supports collations' do
1552
+ min_server_fcv '3.4'
1524
1553
 
1525
1554
  it 'applies the collation' do
1526
1555
  expect(result.written_count).to eq(1)
@@ -1528,7 +1557,8 @@ describe Mongo::Collection::View::Writable do
1528
1557
  end
1529
1558
  end
1530
1559
 
1531
- context 'when the server selected does not support collations', unless: collation_enabled? do
1560
+ context 'when the server selected does not support collations' do
1561
+ max_server_version '3.2'
1532
1562
 
1533
1563
  it 'raises an exception' do
1534
1564
  expect {
@@ -1569,7 +1599,8 @@ describe Mongo::Collection::View::Writable do
1569
1599
  { collation: { locale: 'en_US', strength: 2 } }
1570
1600
  end
1571
1601
 
1572
- context 'when the server selected supports collations', if: collation_enabled? do
1602
+ context 'when the server selected supports collations' do
1603
+ min_server_fcv '3.4'
1573
1604
 
1574
1605
  it 'applies the collation' do
1575
1606
  expect(result.written_count).to eq(1)
@@ -1577,7 +1608,8 @@ describe Mongo::Collection::View::Writable do
1577
1608
  end
1578
1609
  end
1579
1610
 
1580
- context 'when the server selected does not support collations', unless: collation_enabled? do
1611
+ context 'when the server selected does not support collations' do
1612
+ max_server_version '3.2'
1581
1613
 
1582
1614
  it 'raises an exception' do
1583
1615
  expect {
@@ -170,14 +170,16 @@ describe Mongo::Collection::View do
170
170
  view.limit(-1).first
171
171
  end
172
172
 
173
- context 'when the server selected supports collations', if: collation_enabled? do
173
+ context 'when the server selected supports collations' do
174
+ min_server_fcv '3.4'
174
175
 
175
176
  it 'applies the collation' do
176
177
  expect(result['name']).to eq('bang')
177
178
  end
178
179
  end
179
180
 
180
- context 'when the server selected does not support collations', unless: collation_enabled? do
181
+ context 'when the server selected does not support collations' do
182
+ max_server_version '3.2'
181
183
 
182
184
  it 'raises an exception' do
183
185
  expect {
@@ -475,7 +475,7 @@ describe Mongo::Collection do
475
475
  it_behaves_like 'a capped collection command'
476
476
 
477
477
  context 'when validators can be set' do
478
- min_server_version '3.2'
478
+ min_server_fcv '3.2'
479
479
  it_behaves_like 'a validated collection command'
480
480
  end
481
481
  end
@@ -489,7 +489,7 @@ describe Mongo::Collection do
489
489
  it_behaves_like 'a capped collection command'
490
490
 
491
491
  context 'when validators can be set' do
492
- min_server_version '3.2'
492
+ min_server_fcv '3.2'
493
493
  it_behaves_like 'a validated collection command'
494
494
  end
495
495
  end
@@ -511,7 +511,9 @@ describe Mongo::Collection do
511
511
  described_class.new(database, :specs, options)
512
512
  end
513
513
 
514
- context 'when the server supports write concern on the create command', if: replica_set? && collation_enabled? do
514
+ context 'when the server supports write concern on the create command' do
515
+ min_server_fcv '3.4'
516
+ require_topology :replica_set
515
517
 
516
518
  it 'applies the write concern' do
517
519
  expect{
@@ -520,7 +522,8 @@ describe Mongo::Collection do
520
522
  end
521
523
  end
522
524
 
523
- context 'when the server does not support write concern on the create command', unless: collation_enabled? do
525
+ context 'when the server does not support write concern on the create command' do
526
+ max_server_version '3.2'
524
527
 
525
528
  it 'does not apply the write concern' do
526
529
  expect(collection.create).to be_successful
@@ -548,7 +551,8 @@ describe Mongo::Collection do
548
551
  collection.drop
549
552
  end
550
553
 
551
- context 'when the server supports collations', if: collation_enabled? do
554
+ context 'when the server supports collations' do
555
+ min_server_fcv '3.4'
552
556
 
553
557
  it 'executes the command' do
554
558
  expect(response).to be_successful
@@ -565,7 +569,8 @@ describe Mongo::Collection do
565
569
  end
566
570
  end
567
571
 
568
- context 'when the server does not support collations', unless: collation_enabled? do
572
+ context 'when the server does not support collations' do
573
+ max_server_version '3.2'
569
574
 
570
575
  it 'raises an error' do
571
576
  expect {
@@ -678,10 +683,11 @@ describe Mongo::Collection do
678
683
 
679
684
  it_behaves_like 'an operation using a session'
680
685
 
681
- # Due to how rspec interprets nested `if: condition` guards, we can't use one to skip this
682
- # test in the case that the server will override the write concern (preventing the expected
683
- # failure), so we're forced to use a traditional conditional to avoid defining the test.
684
- it_behaves_like 'a failed operation using a session' if can_set_write_concern?
686
+ context 'can set write concern' do
687
+ require_set_write_concern
688
+
689
+ it_behaves_like 'a failed operation using a session'
690
+ end
685
691
  end
686
692
 
687
693
  context 'when the collection does not have a write concern set' do
@@ -698,7 +704,8 @@ describe Mongo::Collection do
698
704
  expect(database.collection_names).to_not include('specs')
699
705
  end
700
706
 
701
- context 'when the collection does not exist', if: can_set_write_concern? do
707
+ context 'when the collection does not exist' do
708
+ require_set_write_concern
702
709
 
703
710
  it 'does not raise an error' do
704
711
  expect(database['non-existent-coll'].drop).to be(false)
@@ -718,7 +725,9 @@ describe Mongo::Collection do
718
725
  collection.with(write_options)
719
726
  end
720
727
 
721
- context 'when the server supports write concern on the drop command', if: collation_enabled? && can_set_write_concern? do
728
+ context 'when the server supports write concern on the drop command' do
729
+ min_server_fcv '3.4'
730
+ require_set_write_concern
722
731
 
723
732
  it 'applies the write concern' do
724
733
  expect{
@@ -727,7 +736,8 @@ describe Mongo::Collection do
727
736
  end
728
737
  end
729
738
 
730
- context 'when the server does not support write concern on the drop command', unless: collation_enabled? do
739
+ context 'when the server does not support write concern on the drop command' do
740
+ max_server_version '3.2'
731
741
 
732
742
  it 'does not apply the write concern' do
733
743
  expect(collection_with_write_options.drop).to be_successful
@@ -736,7 +746,9 @@ describe Mongo::Collection do
736
746
  end
737
747
  end
738
748
 
739
- context 'when the collection does not exist', if: can_set_write_concern? do
749
+ context 'when the collection does not exist' do
750
+ require_set_write_concern
751
+
740
752
  before do
741
753
  begin
742
754
  collection.drop
@@ -821,7 +833,8 @@ describe Mongo::Collection do
821
833
  end
822
834
  end
823
835
 
824
- context 'when the user is not authorized', if: auth_enabled? do
836
+ context 'when the user is not authorized' do
837
+ require_auth
825
838
 
826
839
  let(:view) do
827
840
  unauthorized_collection.find
@@ -886,7 +899,7 @@ describe Mongo::Collection do
886
899
  end
887
900
 
888
901
  context 'session id' do
889
- min_server_version '3.6'
902
+ min_server_fcv '3.6'
890
903
  require_topology :replica_set, :sharded
891
904
 
892
905
  let(:options) do
@@ -1207,7 +1220,7 @@ describe Mongo::Collection do
1207
1220
  end
1208
1221
 
1209
1222
  context 'when the documents are sent with OP_MSG' do
1210
- min_server_version '3.6'
1223
+ min_server_fcv '3.6'
1211
1224
 
1212
1225
  let(:client) do
1213
1226
  subscribed_client
@@ -1236,7 +1249,7 @@ describe Mongo::Collection do
1236
1249
  end
1237
1250
 
1238
1251
  context 'when collection has a validator' do
1239
- min_server_version '3.2'
1252
+ min_server_fcv '3.2'
1240
1253
 
1241
1254
  around(:each) do |spec|
1242
1255
  authorized_client[:validating].drop
@@ -1444,7 +1457,7 @@ describe Mongo::Collection do
1444
1457
  end
1445
1458
 
1446
1459
  context 'when collection has a validator' do
1447
- min_server_version '3.2'
1460
+ min_server_fcv '3.2'
1448
1461
 
1449
1462
  around(:each) do |spec|
1450
1463
  authorized_client[:validating,
@@ -1549,7 +1562,7 @@ describe Mongo::Collection do
1549
1562
  it_behaves_like 'a failed operation using a session'
1550
1563
  end
1551
1564
 
1552
- context 'when batch size is specified', unless: need_to_skip_on_sharded_auth_40? do
1565
+ context 'when batch size is specified' do
1553
1566
 
1554
1567
  let(:batch_size) { 1 }
1555
1568
 
@@ -1668,14 +1681,16 @@ describe Mongo::Collection do
1668
1681
  authorized_collection.aggregate(pipeline, options).collect { |doc| doc['name']}
1669
1682
  end
1670
1683
 
1671
- context 'when the server selected supports collations', if: collation_enabled? do
1684
+ context 'when the server selected supports collations' do
1685
+ min_server_fcv '3.4'
1672
1686
 
1673
1687
  it 'applies the collation' do
1674
1688
  expect(result).to eq(['bang', 'bang'])
1675
1689
  end
1676
1690
  end
1677
1691
 
1678
- context 'when the server selected does not support collations', unless: collation_enabled? do
1692
+ context 'when the server selected does not support collations' do
1693
+ max_server_version '3.2'
1679
1694
 
1680
1695
  it 'raises an exception' do
1681
1696
  expect {
@@ -1700,6 +1715,42 @@ describe Mongo::Collection do
1700
1715
  end
1701
1716
  end
1702
1717
 
1718
+ describe '#count_documents' do
1719
+ context 'when transactions are enabled' do
1720
+ require_transaction_support
1721
+
1722
+ before do
1723
+ # Ensure that the collection is created
1724
+ authorized_collection.insert_one(x: 1)
1725
+ authorized_collection.delete_many({})
1726
+ end
1727
+
1728
+ let(:session) do
1729
+ authorized_client.start_session
1730
+ end
1731
+
1732
+ it 'successfully starts a transaction and executes a transaction' do
1733
+ session.start_transaction
1734
+ expect(
1735
+ session.instance_variable_get(:@state)
1736
+ ).to eq(Mongo::Session::STARTING_TRANSACTION_STATE)
1737
+
1738
+ expect(authorized_collection.count_documents({}, { session: session })).to eq(0)
1739
+ expect(
1740
+ session.instance_variable_get(:@state)
1741
+ ).to eq(Mongo::Session::TRANSACTION_IN_PROGRESS_STATE)
1742
+
1743
+ authorized_collection.insert_one({ x: 1 }, { session: session })
1744
+ expect(authorized_collection.count_documents({}, { session: session })).to eq(1)
1745
+
1746
+ session.commit_transaction
1747
+ expect(
1748
+ session.instance_variable_get(:@state)
1749
+ ).to eq(Mongo::Session::TRANSACTION_COMMITTED_STATE)
1750
+ end
1751
+ end
1752
+ end
1753
+
1703
1754
  describe '#count' do
1704
1755
 
1705
1756
  let(:documents) do
@@ -1774,14 +1825,16 @@ describe Mongo::Collection do
1774
1825
  { collation: { locale: 'en_US', strength: 2 } }
1775
1826
  end
1776
1827
 
1777
- context 'when the server selected supports collations', if: collation_enabled? do
1828
+ context 'when the server selected supports collations' do
1829
+ min_server_fcv '3.4'
1778
1830
 
1779
1831
  it 'applies the collation to the count' do
1780
1832
  expect(result).to eq(1)
1781
1833
  end
1782
1834
  end
1783
1835
 
1784
- context 'when the server selected does not support collations', unless: collation_enabled? do
1836
+ context 'when the server selected does not support collations' do
1837
+ max_server_version '3.2'
1785
1838
 
1786
1839
  it 'raises an exception' do
1787
1840
  expect {
@@ -1885,14 +1938,16 @@ describe Mongo::Collection do
1885
1938
  { collation: { locale: 'en_US', strength: 2 } }
1886
1939
  end
1887
1940
 
1888
- context 'when the server selected supports collations', if: collation_enabled? do
1941
+ context 'when the server selected supports collations' do
1942
+ min_server_fcv '3.4'
1889
1943
 
1890
1944
  it 'applies the collation to the distinct' do
1891
1945
  expect(result).to eq(['bang'])
1892
1946
  end
1893
1947
  end
1894
1948
 
1895
- context 'when the server selected does not support collations', unless: collation_enabled? do
1949
+ context 'when the server selected does not support collations' do
1950
+ max_server_version '3.2'
1896
1951
 
1897
1952
  it 'raises an exception' do
1898
1953
  expect {
@@ -1972,7 +2027,8 @@ describe Mongo::Collection do
1972
2027
  end
1973
2028
  end
1974
2029
 
1975
- context 'when the delete fails', if: standalone? do
2030
+ context 'when the delete fails' do
2031
+ require_topology :single
1976
2032
 
1977
2033
  let(:result) do
1978
2034
  collection_invalid_write_concern.delete_one
@@ -2051,7 +2107,8 @@ describe Mongo::Collection do
2051
2107
  { collation: { locale: 'en_US', strength: 2 } }
2052
2108
  end
2053
2109
 
2054
- context 'when the server selected supports collations', if: collation_enabled? do
2110
+ context 'when the server selected supports collations' do
2111
+ min_server_fcv '3.4'
2055
2112
 
2056
2113
  it 'applies the collation' do
2057
2114
  expect(result.written_count).to eq(1)
@@ -2089,7 +2146,8 @@ describe Mongo::Collection do
2089
2146
  end
2090
2147
  end
2091
2148
 
2092
- context 'when the server selected does not support collations', unless: collation_enabled? do
2149
+ context 'when the server selected does not support collations' do
2150
+ max_server_version '3.2'
2093
2151
 
2094
2152
  it 'raises an exception' do
2095
2153
  expect {
@@ -2157,7 +2215,8 @@ describe Mongo::Collection do
2157
2215
  end
2158
2216
  end
2159
2217
 
2160
- context 'when the deletes fail', if: standalone? do
2218
+ context 'when the deletes fail' do
2219
+ require_topology :single
2161
2220
 
2162
2221
  let(:result) do
2163
2222
  collection_invalid_write_concern.delete_many
@@ -2237,7 +2296,8 @@ describe Mongo::Collection do
2237
2296
  { collation: { locale: 'en_US', strength: 2 } }
2238
2297
  end
2239
2298
 
2240
- context 'when the server selected supports collations', if: collation_enabled? do
2299
+ context 'when the server selected supports collations' do
2300
+ min_server_fcv '3.4'
2241
2301
 
2242
2302
  it 'applies the collation' do
2243
2303
  expect(result.written_count).to eq(2)
@@ -2275,7 +2335,8 @@ describe Mongo::Collection do
2275
2335
  end
2276
2336
  end
2277
2337
 
2278
- context 'when the server selected does not support collations', unless: collation_enabled? do
2338
+ context 'when the server selected does not support collations' do
2339
+ max_server_version '3.2'
2279
2340
 
2280
2341
  it 'raises an exception' do
2281
2342
  expect {
@@ -2320,8 +2381,9 @@ describe Mongo::Collection do
2320
2381
  end
2321
2382
  end
2322
2383
 
2323
- describe '#parallel_scan', unless: sharded? do
2384
+ describe '#parallel_scan' do
2324
2385
  max_server_version '4.0'
2386
+ require_topology :single, :replica_set
2325
2387
 
2326
2388
  let(:documents) do
2327
2389
  (1..200).map do |i|
@@ -2419,7 +2481,7 @@ describe Mongo::Collection do
2419
2481
  end
2420
2482
 
2421
2483
  context 'when a read concern is provided' do
2422
- min_server_version '3.2'
2484
+ min_server_fcv '3.2'
2423
2485
 
2424
2486
  let(:result) do
2425
2487
  authorized_collection.with(options).parallel_scan(2)
@@ -2450,7 +2512,8 @@ describe Mongo::Collection do
2450
2512
  end
2451
2513
  end
2452
2514
 
2453
- context 'when the collection has a read preference', unless: sharded? do
2515
+ context 'when the collection has a read preference' do
2516
+ require_topology :single, :replica_set
2454
2517
 
2455
2518
  before do
2456
2519
  allow(collection.client.cluster).to receive(:single?).and_return(false)
@@ -2480,7 +2543,8 @@ describe Mongo::Collection do
2480
2543
  end
2481
2544
  end
2482
2545
 
2483
- context 'when a max time ms value is provided', if: !sharded? do
2546
+ context 'when a max time ms value is provided' do
2547
+ require_topology :single, :replica_set
2484
2548
 
2485
2549
  let(:result) do
2486
2550
  authorized_collection.parallel_scan(2, options)
@@ -2612,7 +2676,7 @@ describe Mongo::Collection do
2612
2676
  end
2613
2677
 
2614
2678
  context 'when collection has a validator' do
2615
- min_server_version '3.2'
2679
+ min_server_fcv '3.2'
2616
2680
 
2617
2681
  around(:each) do |spec|
2618
2682
  authorized_client[:validating,
@@ -2685,7 +2749,8 @@ describe Mongo::Collection do
2685
2749
  { collation: { locale: 'en_US', strength: 2 } }
2686
2750
  end
2687
2751
 
2688
- context 'when the server selected supports collations', if: collation_enabled? do
2752
+ context 'when the server selected supports collations' do
2753
+ min_server_fcv '3.4'
2689
2754
 
2690
2755
  it 'applies the collation' do
2691
2756
  expect(result.written_count).to eq(1)
@@ -2723,7 +2788,8 @@ describe Mongo::Collection do
2723
2788
  end
2724
2789
  end
2725
2790
 
2726
- context 'when the server selected does not support collations', unless: collation_enabled? do
2791
+ context 'when the server selected does not support collations' do
2792
+ max_server_version '3.2'
2727
2793
 
2728
2794
  it 'raises an exception' do
2729
2795
  expect {
@@ -2917,7 +2983,8 @@ describe Mongo::Collection do
2917
2983
  { '$or' => [{ _id: 0 }, { _id: 1 }]}
2918
2984
  end
2919
2985
 
2920
- context 'when the server supports arrayFilters', if: array_filters_enabled? do
2986
+ context 'when the server supports arrayFilters' do
2987
+ min_server_fcv '3.6'
2921
2988
 
2922
2989
  before do
2923
2990
  authorized_collection.insert_many([{
@@ -2975,7 +3042,8 @@ describe Mongo::Collection do
2975
3042
  end
2976
3043
  end
2977
3044
 
2978
- context 'when the server does not support arrayFilters', unless: array_filters_enabled? do
3045
+ context 'when the server does not support arrayFilters' do
3046
+ max_server_version '3.4'
2979
3047
 
2980
3048
  let(:result) do
2981
3049
  authorized_collection.update_many(selector,
@@ -3025,7 +3093,7 @@ describe Mongo::Collection do
3025
3093
  end
3026
3094
 
3027
3095
  context 'when collection has a validator' do
3028
- min_server_version '3.2'
3096
+ min_server_fcv '3.2'
3029
3097
 
3030
3098
  around(:each) do |spec|
3031
3099
  authorized_client[:validating,
@@ -3102,7 +3170,8 @@ describe Mongo::Collection do
3102
3170
  { collation: { locale: 'en_US', strength: 2 } }
3103
3171
  end
3104
3172
 
3105
- context 'when the server selected supports collations', if: collation_enabled? do
3173
+ context 'when the server selected supports collations' do
3174
+ min_server_fcv '3.4'
3106
3175
 
3107
3176
  it 'applies the collation' do
3108
3177
  expect(result.written_count).to eq(2)
@@ -3140,7 +3209,8 @@ describe Mongo::Collection do
3140
3209
  end
3141
3210
  end
3142
3211
 
3143
- context 'when the server selected does not support collations', unless: collation_enabled? do
3212
+ context 'when the server selected does not support collations' do
3213
+ max_server_version '3.2'
3144
3214
 
3145
3215
  it 'raises an exception' do
3146
3216
  expect {
@@ -3343,7 +3413,7 @@ describe Mongo::Collection do
3343
3413
  end
3344
3414
 
3345
3415
  context 'when collection has a validator' do
3346
- min_server_version '3.2'
3416
+ min_server_fcv '3.2'
3347
3417
 
3348
3418
  around(:each) do |spec|
3349
3419
  authorized_client[:validating,
@@ -3419,7 +3489,8 @@ describe Mongo::Collection do
3419
3489
  { collation: { locale: 'en_US', strength: 2 } }
3420
3490
  end
3421
3491
 
3422
- context 'when the server selected supports collations', if: collation_enabled? do
3492
+ context 'when the server selected supports collations' do
3493
+ min_server_fcv '3.4'
3423
3494
 
3424
3495
  it 'applies the collation' do
3425
3496
  expect(result.written_count).to eq(1)
@@ -3457,7 +3528,8 @@ describe Mongo::Collection do
3457
3528
  end
3458
3529
  end
3459
3530
 
3460
- context 'when the server selected does not support collations', unless: collation_enabled? do
3531
+ context 'when the server selected does not support collations' do
3532
+ max_server_version '3.2'
3461
3533
 
3462
3534
  it 'raises an exception' do
3463
3535
  expect {
@@ -3506,7 +3578,8 @@ describe Mongo::Collection do
3506
3578
  { _id: 0}
3507
3579
  end
3508
3580
 
3509
- context 'when the server supports arrayFilters', if: array_filters_enabled? do
3581
+ context 'when the server supports arrayFilters' do
3582
+ min_server_fcv '3.6'
3510
3583
 
3511
3584
  before do
3512
3585
  authorized_collection.insert_one(_id: 0, x: [{ y: 1 }, { y: 2 }, {y: 3 }])
@@ -3545,7 +3618,8 @@ describe Mongo::Collection do
3545
3618
  end
3546
3619
  end
3547
3620
 
3548
- context 'when the server does not support arrayFilters', unless: array_filters_enabled? do
3621
+ context 'when the server does not support arrayFilters' do
3622
+ max_server_version '3.4'
3549
3623
 
3550
3624
  let(:result) do
3551
3625
  authorized_collection.update_one(selector,
@@ -3582,7 +3656,7 @@ describe Mongo::Collection do
3582
3656
  end
3583
3657
 
3584
3658
  context 'when the documents are sent with OP_MSG' do
3585
- min_server_version '3.6'
3659
+ min_server_fcv '3.6'
3586
3660
 
3587
3661
  let(:client) do
3588
3662
  subscribed_client
@@ -3781,8 +3855,9 @@ describe Mongo::Collection do
3781
3855
  end
3782
3856
  end
3783
3857
 
3784
- context 'when write_concern is provided', if: standalone? do
3785
- min_server_version '3.2'
3858
+ context 'when write_concern is provided' do
3859
+ min_server_fcv '3.2'
3860
+ require_topology :single
3786
3861
 
3787
3862
  it 'uses the write concern' do
3788
3863
  expect {
@@ -3792,8 +3867,9 @@ describe Mongo::Collection do
3792
3867
  end
3793
3868
  end
3794
3869
 
3795
- context 'when the collection has a write concern', if: standalone? do
3796
- min_server_version '3.2'
3870
+ context 'when the collection has a write concern' do
3871
+ min_server_fcv '3.2'
3872
+ require_topology :single
3797
3873
 
3798
3874
  let(:collection) do
3799
3875
  authorized_collection.with(write: { w: 2 })
@@ -3825,7 +3901,8 @@ describe Mongo::Collection do
3825
3901
  { collation: { locale: 'en_US', strength: 2 } }
3826
3902
  end
3827
3903
 
3828
- context 'when the server selected supports collations', if: collation_enabled? do
3904
+ context 'when the server selected supports collations' do
3905
+ min_server_fcv '3.4'
3829
3906
 
3830
3907
  it 'applies the collation' do
3831
3908
  expect(result['name']).to eq('bang')
@@ -3833,7 +3910,8 @@ describe Mongo::Collection do
3833
3910
  end
3834
3911
  end
3835
3912
 
3836
- context 'when the server selected does not support collations', unless: collation_enabled? do
3913
+ context 'when the server selected does not support collations' do
3914
+ max_server_version '3.2'
3837
3915
 
3838
3916
  it 'raises an exception' do
3839
3917
  expect {
@@ -4052,7 +4130,7 @@ describe Mongo::Collection do
4052
4130
  end
4053
4131
 
4054
4132
  context 'when collection has a validator' do
4055
- min_server_version '3.2'
4133
+ min_server_fcv '3.2'
4056
4134
 
4057
4135
  around(:each) do |spec|
4058
4136
  authorized_client[:validating].drop
@@ -4112,8 +4190,9 @@ describe Mongo::Collection do
4112
4190
  end
4113
4191
  end
4114
4192
 
4115
- context 'when write_concern is provided', if: standalone? do
4116
- min_server_version '3.2'
4193
+ context 'when write_concern is provided' do
4194
+ min_server_fcv '3.2'
4195
+ require_topology :single
4117
4196
 
4118
4197
  it 'uses the write concern' do
4119
4198
  expect {
@@ -4124,8 +4203,9 @@ describe Mongo::Collection do
4124
4203
  end
4125
4204
  end
4126
4205
 
4127
- context 'when the collection has a write concern', if: standalone? do
4128
- min_server_version '3.2'
4206
+ context 'when the collection has a write concern' do
4207
+ min_server_fcv '3.2'
4208
+ require_topology :single
4129
4209
 
4130
4210
  let(:collection) do
4131
4211
  authorized_collection.with(write: { w: 2 })
@@ -4160,7 +4240,8 @@ describe Mongo::Collection do
4160
4240
  { collation: { locale: 'en_US', strength: 2 } }
4161
4241
  end
4162
4242
 
4163
- context 'when the server selected supports collations', if: collation_enabled? do
4243
+ context 'when the server selected supports collations' do
4244
+ min_server_fcv '3.4'
4164
4245
 
4165
4246
  it 'applies the collation' do
4166
4247
  expect(result['name']).to eq('bang')
@@ -4168,7 +4249,8 @@ describe Mongo::Collection do
4168
4249
  end
4169
4250
  end
4170
4251
 
4171
- context 'when the server selected does not support collations', unless: collation_enabled? do
4252
+ context 'when the server selected does not support collations' do
4253
+ max_server_version '3.2'
4172
4254
 
4173
4255
  it 'raises an exception' do
4174
4256
  expect {
@@ -4216,7 +4298,8 @@ describe Mongo::Collection do
4216
4298
  { _id: 0 }
4217
4299
  end
4218
4300
 
4219
- context 'when the server supports arrayFilters', if: array_filters_enabled? do
4301
+ context 'when the server supports arrayFilters' do
4302
+ min_server_fcv '3.6'
4220
4303
 
4221
4304
  before do
4222
4305
  authorized_collection.insert_one(_id: 0, x: [{ y: 1 }, { y: 2 }, { y: 3 }])
@@ -4254,7 +4337,8 @@ describe Mongo::Collection do
4254
4337
  end
4255
4338
  end
4256
4339
 
4257
- context 'when the server selected does not support arrayFilters', unless: array_filters_enabled? do
4340
+ context 'when the server selected does not support arrayFilters' do
4341
+ max_server_version '3.4'
4258
4342
 
4259
4343
  let(:result) do
4260
4344
  authorized_collection.find_one_and_update(selector,
@@ -4441,7 +4525,7 @@ describe Mongo::Collection do
4441
4525
  end
4442
4526
 
4443
4527
  context 'when collection has a validator' do
4444
- min_server_version '3.2'
4528
+ min_server_fcv '3.2'
4445
4529
 
4446
4530
  around(:each) do |spec|
4447
4531
  authorized_client[:validating].drop
@@ -4501,8 +4585,9 @@ describe Mongo::Collection do
4501
4585
  end
4502
4586
  end
4503
4587
 
4504
- context 'when write_concern is provided', if: standalone? do
4505
- min_server_version '3.2'
4588
+ context 'when write_concern is provided' do
4589
+ min_server_fcv '3.2'
4590
+ require_topology :single
4506
4591
 
4507
4592
  it 'uses the write concern' do
4508
4593
  expect {
@@ -4513,8 +4598,9 @@ describe Mongo::Collection do
4513
4598
  end
4514
4599
  end
4515
4600
 
4516
- context 'when the collection has a write concern', if: standalone? do
4517
- min_server_version '3.2'
4601
+ context 'when the collection has a write concern' do
4602
+ min_server_fcv '3.2'
4603
+ require_topology :single
4518
4604
 
4519
4605
  let(:collection) do
4520
4606
  authorized_collection.with(write: { w: 2 })
@@ -4549,7 +4635,8 @@ describe Mongo::Collection do
4549
4635
  { collation: { locale: 'en_US', strength: 2 } }
4550
4636
  end
4551
4637
 
4552
- context 'when the server selected supports collations', if: collation_enabled? do
4638
+ context 'when the server selected supports collations' do
4639
+ min_server_fcv '3.4'
4553
4640
 
4554
4641
  it 'applies the collation' do
4555
4642
  expect(result['name']).to eq('bang')
@@ -4557,7 +4644,8 @@ describe Mongo::Collection do
4557
4644
  end
4558
4645
  end
4559
4646
 
4560
- context 'when the server selected does not support collations', unless: collation_enabled? do
4647
+ context 'when the server selected does not support collations' do
4648
+ max_server_version '3.2'
4561
4649
 
4562
4650
  it 'raises an exception' do
4563
4651
  expect {
@@ -4602,7 +4690,9 @@ describe Mongo::Collection do
4602
4690
 
4603
4691
  describe '#watch' do
4604
4692
 
4605
- context 'when change streams can be tested', if: test_change_streams? do
4693
+ context 'when change streams can be tested' do
4694
+ min_server_fcv '3.6'
4695
+ require_topology :replica_set
4606
4696
 
4607
4697
  let(:change_stream) do
4608
4698
  authorized_collection.watch