mongo 2.1.0.beta → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (342) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +10 -3
  4. data/Rakefile +1 -7
  5. data/lib/mongo/address/ipv4.rb +6 -1
  6. data/lib/mongo/address/unix.rb +2 -2
  7. data/lib/mongo/address.rb +32 -10
  8. data/lib/mongo/auth/cr/conversation.rb +1 -1
  9. data/lib/mongo/auth/ldap/conversation.rb +7 -3
  10. data/lib/mongo/auth/scram/conversation.rb +9 -3
  11. data/lib/mongo/auth/user/view.rb +23 -2
  12. data/lib/mongo/auth/x509/conversation.rb +1 -1
  13. data/lib/mongo/bulk_write/combineable.rb +51 -0
  14. data/lib/mongo/bulk_write/ordered_combiner.rb +55 -0
  15. data/lib/mongo/bulk_write/result.rb +61 -8
  16. data/lib/mongo/bulk_write/result_combiner.rb +117 -0
  17. data/lib/mongo/bulk_write/transformable.rb +132 -0
  18. data/lib/mongo/bulk_write/unordered_combiner.rb +52 -0
  19. data/lib/mongo/bulk_write/validatable.rb +62 -0
  20. data/lib/mongo/bulk_write.rb +164 -23
  21. data/lib/mongo/client.rb +75 -18
  22. data/lib/mongo/cluster/topology/replica_set.rb +8 -6
  23. data/lib/mongo/cluster/topology/unknown.rb +5 -2
  24. data/lib/mongo/cluster.rb +85 -5
  25. data/lib/mongo/collection/view/aggregation.rb +19 -45
  26. data/lib/mongo/collection/view/builder/aggregation.rb +98 -0
  27. data/lib/mongo/collection/view/builder/find_command.rb +111 -0
  28. data/lib/mongo/collection/view/builder/flags.rb +62 -0
  29. data/lib/mongo/collection/view/builder/map_reduce.rb +134 -0
  30. data/lib/mongo/collection/view/builder/modifiers.rb +80 -0
  31. data/lib/mongo/collection/view/builder/op_query.rb +83 -0
  32. data/lib/mongo/collection/view/builder.rb +20 -0
  33. data/lib/mongo/collection/view/explainable.rb +15 -0
  34. data/lib/mongo/collection/view/immutable.rb +4 -11
  35. data/lib/mongo/collection/view/iterable.rb +40 -5
  36. data/lib/mongo/collection/view/map_reduce.rb +67 -37
  37. data/lib/mongo/collection/view/readable.rb +114 -100
  38. data/lib/mongo/collection/view/writable.rb +46 -22
  39. data/lib/mongo/collection/view.rb +25 -22
  40. data/lib/mongo/collection.rb +130 -12
  41. data/lib/mongo/cursor/builder/get_more_command.rb +71 -0
  42. data/lib/mongo/cursor/builder/kill_cursors_command.rb +62 -0
  43. data/lib/mongo/cursor/builder/op_get_more.rb +61 -0
  44. data/lib/mongo/cursor/builder/op_kill_cursors.rb +56 -0
  45. data/lib/mongo/cursor/builder.rb +18 -0
  46. data/lib/mongo/cursor.rb +76 -21
  47. data/lib/mongo/database/view.rb +11 -6
  48. data/lib/mongo/database.rb +16 -6
  49. data/lib/mongo/dbref.rb +9 -9
  50. data/lib/mongo/{bulk_write/unordered_bulk_write.rb → error/closed_stream.rb} +12 -21
  51. data/lib/mongo/{bulk_write/ordered_bulk_write.rb → error/extra_file_chunk.rb} +13 -27
  52. data/lib/mongo/error/file_not_found.rb +37 -0
  53. data/lib/mongo/error/invalid_file.rb +2 -2
  54. data/lib/mongo/error/invalid_file_revision.rb +37 -0
  55. data/lib/mongo/error/invalid_uri.rb +5 -4
  56. data/lib/mongo/error/invalid_write_concern.rb +35 -0
  57. data/lib/mongo/error/missing_file_chunk.rb +38 -0
  58. data/lib/mongo/error/operation_failure.rb +33 -2
  59. data/lib/mongo/error/unchangeable_collection_option.rb +38 -0
  60. data/lib/mongo/error/unexpected_chunk_length.rb +39 -0
  61. data/lib/mongo/error.rb +8 -0
  62. data/lib/mongo/grid/file/chunk.rb +9 -9
  63. data/lib/mongo/grid/file/{metadata.rb → info.rb} +41 -39
  64. data/lib/mongo/grid/file.rb +12 -9
  65. data/lib/mongo/grid/fs_bucket.rb +448 -0
  66. data/lib/mongo/grid/stream/read.rb +208 -0
  67. data/lib/mongo/grid/stream/write.rb +187 -0
  68. data/lib/mongo/grid/stream.rb +64 -0
  69. data/lib/mongo/grid.rb +2 -1
  70. data/lib/mongo/index/view.rb +7 -4
  71. data/lib/mongo/index.rb +5 -0
  72. data/lib/mongo/loggable.rb +34 -57
  73. data/lib/mongo/logger.rb +16 -78
  74. data/lib/mongo/monitoring/command_log_subscriber.rb +38 -14
  75. data/lib/mongo/monitoring/event/command_started.rb +2 -1
  76. data/lib/mongo/monitoring/event/command_succeeded.rb +24 -2
  77. data/lib/mongo/monitoring/event/secure.rb +58 -0
  78. data/lib/mongo/monitoring/event.rb +1 -0
  79. data/lib/mongo/monitoring/publishable.rb +22 -12
  80. data/lib/mongo/monitoring.rb +1 -5
  81. data/lib/mongo/operation/commands/aggregate/result.rb +89 -0
  82. data/lib/mongo/operation/commands/aggregate.rb +64 -0
  83. data/lib/mongo/operation/commands/collections_info/result.rb +41 -0
  84. data/lib/mongo/operation/{read → commands}/collections_info.rb +5 -3
  85. data/lib/mongo/operation/commands/command.rb +47 -0
  86. data/lib/mongo/operation/commands/find/result.rb +62 -0
  87. data/lib/mongo/operation/commands/find.rb +27 -0
  88. data/lib/mongo/operation/commands/get_more/result.rb +62 -0
  89. data/lib/mongo/operation/commands/get_more.rb +27 -0
  90. data/lib/mongo/operation/{read → commands}/indexes.rb +9 -6
  91. data/lib/mongo/operation/{list_collections → commands/list_collections}/result.rb +1 -21
  92. data/lib/mongo/operation/{read → commands}/list_collections.rb +4 -32
  93. data/lib/mongo/operation/{list_indexes → commands/list_indexes}/result.rb +1 -21
  94. data/lib/mongo/operation/{read → commands}/list_indexes.rb +3 -33
  95. data/lib/mongo/operation/commands/map_reduce/result.rb +119 -0
  96. data/lib/mongo/operation/commands/map_reduce.rb +49 -0
  97. data/lib/mongo/operation/commands/parallel_scan/result.rb +64 -0
  98. data/lib/mongo/operation/commands/parallel_scan.rb +52 -0
  99. data/lib/mongo/operation/commands/user_query.rb +71 -0
  100. data/lib/mongo/operation/commands/users_info/result.rb +38 -0
  101. data/lib/mongo/operation/commands/users_info.rb +48 -0
  102. data/lib/mongo/operation/commands.rb +26 -0
  103. data/lib/mongo/operation/executable.rb +4 -68
  104. data/lib/mongo/operation/kill_cursors.rb +3 -3
  105. data/lib/mongo/operation/object_id_generator.rb +36 -0
  106. data/lib/mongo/operation/read/get_more.rb +2 -22
  107. data/lib/mongo/operation/read/query/result.rb +40 -0
  108. data/lib/mongo/operation/read/query.rb +4 -21
  109. data/lib/mongo/operation/read.rb +0 -4
  110. data/lib/mongo/operation/{read_preferrable.rb → read_preference.rb} +3 -2
  111. data/lib/mongo/operation/result.rb +43 -1
  112. data/lib/mongo/operation/specifiable.rb +59 -1
  113. data/lib/mongo/operation/write/bulk/bulkable.rb +83 -0
  114. data/lib/mongo/operation/write/bulk/delete/result.rb +67 -0
  115. data/lib/mongo/operation/write/bulk/delete.rb +71 -0
  116. data/lib/mongo/operation/write/bulk/insert/result.rb +129 -0
  117. data/lib/mongo/operation/write/bulk/insert.rb +96 -0
  118. data/lib/mongo/operation/write/bulk/legacy_mergable.rb +87 -0
  119. data/lib/mongo/operation/write/bulk/mergable.rb +71 -0
  120. data/lib/mongo/operation/write/bulk/update/result.rb +174 -0
  121. data/lib/mongo/operation/write/bulk/update.rb +81 -0
  122. data/lib/mongo/operation/write/bulk.rb +6 -3
  123. data/lib/mongo/operation/write/command/create_index.rb +0 -1
  124. data/lib/mongo/operation/write/command/create_user.rb +0 -1
  125. data/lib/mongo/operation/write/command/delete.rb +3 -3
  126. data/lib/mongo/operation/write/command/drop_index.rb +0 -1
  127. data/lib/mongo/operation/write/command/insert.rb +4 -3
  128. data/lib/mongo/operation/write/command/remove_user.rb +0 -1
  129. data/lib/mongo/operation/write/command/update.rb +6 -4
  130. data/lib/mongo/operation/write/command/update_user.rb +0 -1
  131. data/lib/mongo/operation/write/command/writable.rb +13 -18
  132. data/lib/mongo/operation/write/create_index.rb +4 -27
  133. data/lib/mongo/operation/write/create_user.rb +4 -30
  134. data/lib/mongo/operation/write/delete.rb +6 -29
  135. data/lib/mongo/operation/write/drop_index.rb +3 -3
  136. data/lib/mongo/operation/write/gle.rb +49 -0
  137. data/lib/mongo/operation/write/idable.rb +24 -2
  138. data/lib/mongo/operation/write/insert.rb +2 -24
  139. data/lib/mongo/operation/write/remove_user.rb +4 -27
  140. data/lib/mongo/operation/write/update.rb +13 -36
  141. data/lib/mongo/operation/write/update_user.rb +4 -30
  142. data/lib/mongo/operation/write/write_command_enabled.rb +53 -0
  143. data/lib/mongo/operation/write.rb +2 -0
  144. data/lib/mongo/operation.rb +33 -5
  145. data/lib/mongo/options/mapper.rb +26 -2
  146. data/lib/mongo/options/redacted.rb +156 -0
  147. data/lib/mongo/options.rb +1 -0
  148. data/lib/mongo/protocol/bit_vector.rb +11 -9
  149. data/lib/mongo/protocol/delete.rb +78 -3
  150. data/lib/mongo/protocol/get_more.rb +59 -2
  151. data/lib/mongo/protocol/insert.rb +73 -1
  152. data/lib/mongo/protocol/kill_cursors.rb +66 -4
  153. data/lib/mongo/protocol/message.rb +44 -20
  154. data/lib/mongo/protocol/query.rb +153 -65
  155. data/lib/mongo/protocol/reply.rb +92 -1
  156. data/lib/mongo/protocol/serializers.rb +49 -40
  157. data/lib/mongo/protocol/update.rb +93 -1
  158. data/lib/mongo/retryable.rb +101 -0
  159. data/lib/mongo/server/connectable.rb +28 -8
  160. data/lib/mongo/server/connection.rb +52 -10
  161. data/lib/mongo/server/connection_pool/queue.rb +15 -0
  162. data/lib/mongo/server/connection_pool.rb +12 -15
  163. data/lib/mongo/server/description/features.rb +4 -2
  164. data/lib/mongo/server/description.rb +39 -3
  165. data/lib/mongo/server/monitor/connection.rb +49 -28
  166. data/lib/mongo/server/monitor.rb +3 -14
  167. data/lib/mongo/server.rb +31 -4
  168. data/lib/mongo/server_selector/selectable.rb +58 -32
  169. data/lib/mongo/server_selector.rb +19 -10
  170. data/lib/mongo/socket/ssl.rb +4 -1
  171. data/lib/mongo/socket/tcp.rb +2 -2
  172. data/lib/mongo/socket/unix.rb +5 -8
  173. data/lib/mongo/socket.rb +11 -4
  174. data/lib/mongo/uri.rb +245 -139
  175. data/lib/mongo/version.rb +1 -1
  176. data/lib/mongo/write_concern.rb +21 -6
  177. data/lib/mongo.rb +4 -4
  178. data/mongo.gemspec +1 -2
  179. data/spec/mongo/address/unix_spec.rb +1 -1
  180. data/spec/mongo/address_spec.rb +25 -0
  181. data/spec/mongo/auth/ldap/conversation_spec.rb +43 -0
  182. data/spec/mongo/auth/user/view_spec.rb +26 -1
  183. data/spec/mongo/bulk_write/ordered_combiner_spec.rb +284 -0
  184. data/spec/mongo/bulk_write/unordered_combiner_spec.rb +239 -0
  185. data/spec/mongo/bulk_write_spec.rb +385 -161
  186. data/spec/mongo/client_spec.rb +193 -23
  187. data/spec/mongo/cluster/topology/replica_set_spec.rb +2 -0
  188. data/spec/mongo/collection/view/aggregation_spec.rb +65 -0
  189. data/spec/mongo/collection/view/builder/find_command_spec.rb +167 -0
  190. data/spec/mongo/collection/view/builder/flags_spec.rb +106 -0
  191. data/spec/mongo/collection/view/builder/modifiers_spec.rb +210 -0
  192. data/spec/mongo/collection/view/builder/op_query_spec.rb +154 -0
  193. data/spec/mongo/collection/view/explainable_spec.rb +1 -2
  194. data/spec/mongo/collection/view/immutable_spec.rb +54 -0
  195. data/spec/mongo/collection/view/map_reduce_spec.rb +104 -9
  196. data/spec/mongo/collection/view/readable_spec.rb +109 -112
  197. data/spec/mongo/collection/view_spec.rb +119 -487
  198. data/spec/mongo/collection_spec.rb +1002 -33
  199. data/spec/mongo/command_monitoring_spec.rb +64 -0
  200. data/spec/mongo/connection_string_spec.rb +115 -0
  201. data/spec/mongo/cursor/builder/get_more_command_spec.rb +160 -0
  202. data/spec/mongo/cursor/builder/op_get_more_spec.rb +52 -0
  203. data/spec/mongo/cursor_spec.rb +10 -60
  204. data/spec/mongo/database_spec.rb +81 -12
  205. data/spec/mongo/dbref_spec.rb +4 -4
  206. data/spec/mongo/grid/file/chunk_spec.rb +6 -6
  207. data/spec/mongo/grid/file/{metadata_spec.rb → info_spec.rb} +29 -17
  208. data/spec/mongo/grid/file_spec.rb +8 -8
  209. data/spec/mongo/grid/fs_bucket_spec.rb +1020 -0
  210. data/spec/mongo/grid/stream/read_spec.rb +275 -0
  211. data/spec/mongo/grid/stream/write_spec.rb +440 -0
  212. data/spec/mongo/grid/stream_spec.rb +48 -0
  213. data/spec/mongo/gridfs_spec.rb +50 -0
  214. data/spec/mongo/index/view_spec.rb +41 -0
  215. data/spec/mongo/logger_spec.rb +0 -40
  216. data/spec/mongo/monitoring/command_log_subscriber_spec.rb +76 -0
  217. data/spec/mongo/monitoring/event/command_started_spec.rb +26 -0
  218. data/spec/mongo/monitoring/event/command_succeeded_spec.rb +26 -0
  219. data/spec/mongo/monitoring/event/secure_spec.rb +57 -0
  220. data/spec/mongo/operation/{aggregate → commands/aggregate}/result_spec.rb +1 -1
  221. data/spec/mongo/operation/commands/aggregate_spec.rb +69 -0
  222. data/spec/mongo/operation/{read → commands}/collections_info_spec.rb +1 -1
  223. data/spec/mongo/operation/{command_spec.rb → commands/command_spec.rb} +1 -19
  224. data/spec/mongo/operation/{read → commands}/indexes_spec.rb +1 -1
  225. data/spec/mongo/operation/{map_reduce_spec.rb → commands/map_reduce_spec.rb} +1 -19
  226. data/spec/mongo/operation/kill_cursors_spec.rb +1 -17
  227. data/spec/mongo/operation/read/get_more_spec.rb +0 -16
  228. data/spec/mongo/operation/read/query_spec.rb +19 -16
  229. data/spec/mongo/operation/{read_preferrable_spec.rb → read_preference_spec.rb} +11 -11
  230. data/spec/mongo/operation/result_spec.rb +19 -0
  231. data/spec/mongo/operation/write/bulk/{bulk_delete_spec.rb → delete_spec.rb} +17 -28
  232. data/spec/mongo/operation/write/bulk/{bulk_insert_spec.rb → insert_spec.rb} +1 -12
  233. data/spec/mongo/operation/write/bulk/{bulk_update_spec.rb → update_spec.rb} +7 -18
  234. data/spec/mongo/operation/write/command/delete_spec.rb +18 -9
  235. data/spec/mongo/operation/write/command/insert_spec.rb +18 -9
  236. data/spec/mongo/operation/write/command/update_spec.rb +18 -9
  237. data/spec/mongo/operation/write/delete_spec.rb +3 -3
  238. data/spec/mongo/operation/write/insert_spec.rb +0 -11
  239. data/spec/mongo/operation/write/update_spec.rb +6 -6
  240. data/spec/mongo/options/redacted_spec.rb +350 -0
  241. data/spec/mongo/protocol/delete_spec.rb +4 -4
  242. data/spec/mongo/protocol/get_more_spec.rb +4 -4
  243. data/spec/mongo/protocol/insert_spec.rb +3 -3
  244. data/spec/mongo/protocol/kill_cursors_spec.rb +8 -6
  245. data/spec/mongo/protocol/query_spec.rb +21 -7
  246. data/spec/mongo/protocol/update_spec.rb +5 -5
  247. data/spec/mongo/retryable_spec.rb +221 -0
  248. data/spec/mongo/server/connection_pool/queue_spec.rb +16 -0
  249. data/spec/mongo/server/connection_pool_spec.rb +42 -6
  250. data/spec/mongo/server/connection_spec.rb +86 -1
  251. data/spec/mongo/server/description/features_spec.rb +25 -0
  252. data/spec/mongo/server/description_spec.rb +42 -0
  253. data/spec/mongo/server/monitor_spec.rb +44 -0
  254. data/spec/mongo/server_discovery_and_monitoring_spec.rb +25 -59
  255. data/spec/mongo/server_selection_rtt_spec.rb +37 -57
  256. data/spec/mongo/server_selection_spec.rb +5 -3
  257. data/spec/mongo/server_selector/nearest_spec.rb +35 -27
  258. data/spec/mongo/server_selector/primary_preferred_spec.rb +32 -30
  259. data/spec/mongo/server_selector/primary_spec.rb +21 -14
  260. data/spec/mongo/server_selector/secondary_preferred_spec.rb +28 -26
  261. data/spec/mongo/server_selector/secondary_spec.rb +24 -22
  262. data/spec/mongo/server_selector_spec.rb +87 -24
  263. data/spec/mongo/server_spec.rb +78 -15
  264. data/spec/mongo/socket/ssl_spec.rb +101 -57
  265. data/spec/mongo/socket/unix_spec.rb +52 -0
  266. data/spec/mongo/uri_spec.rb +271 -59
  267. data/spec/mongo/write_concern_spec.rb +126 -0
  268. data/spec/spec_helper.rb +29 -23
  269. data/spec/support/authorization.rb +4 -5
  270. data/spec/support/command_monitoring/bulkWrite.yml +73 -0
  271. data/spec/support/command_monitoring/command.yml +42 -0
  272. data/spec/support/command_monitoring/deleteMany.yml +55 -0
  273. data/spec/support/command_monitoring/deleteOne.yml +55 -0
  274. data/spec/support/command_monitoring/find.yml +268 -0
  275. data/spec/support/command_monitoring/insertMany.yml +81 -0
  276. data/spec/support/command_monitoring/insertOne.yml +51 -0
  277. data/spec/support/command_monitoring/updateMany.yml +67 -0
  278. data/spec/support/command_monitoring/updateOne.yml +95 -0
  279. data/spec/support/command_monitoring.rb +373 -0
  280. data/spec/support/connection_string.rb +228 -0
  281. data/spec/support/connection_string_tests/invalid-uris.yml +193 -0
  282. data/spec/support/connection_string_tests/valid-auth.yml +256 -0
  283. data/spec/support/connection_string_tests/valid-host_identifiers.yml +121 -0
  284. data/spec/support/connection_string_tests/valid-options.yml +30 -0
  285. data/spec/support/connection_string_tests/valid-unix_socket-absolute.yml +197 -0
  286. data/spec/support/connection_string_tests/valid-unix_socket-relative.yml +213 -0
  287. data/spec/support/connection_string_tests/valid-warnings.yml +55 -0
  288. data/spec/support/crud/read.rb +14 -10
  289. data/spec/support/crud/write.rb +36 -9
  290. data/spec/support/crud.rb +10 -2
  291. data/spec/support/gridfs.rb +637 -0
  292. data/spec/support/gridfs_tests/delete.yml +157 -0
  293. data/spec/support/gridfs_tests/download.yml +210 -0
  294. data/spec/support/gridfs_tests/download_by_name.yml +113 -0
  295. data/spec/support/gridfs_tests/upload.yml +158 -0
  296. data/spec/support/matchers.rb +2 -2
  297. data/spec/support/sdam/rs/equal_electionids.yml +1 -2
  298. data/spec/support/sdam/rs/new_primary_new_electionid.yml +0 -3
  299. data/spec/support/sdam/rs/primary_mismatched_me.yml +37 -0
  300. data/spec/support/sdam/rs/primary_to_no_primary_mismatched_me.yml +75 -0
  301. data/spec/support/sdam/rs/rsother_discovered.yml +24 -3
  302. data/spec/support/sdam/rs/secondary_mismatched_me.yml +37 -0
  303. data/spec/support/sdam/rs/stepdown_change_set_name.yml +59 -0
  304. data/spec/support/sdam/single/direct_connection_rsarbiter.yml +1 -1
  305. data/spec/support/sdam/single/direct_connection_rsprimary.yml +1 -1
  306. data/spec/support/sdam/single/direct_connection_rssecondary.yml +1 -1
  307. data/spec/support/sdam/single/direct_connection_slave.yml +1 -1
  308. data/spec/support/sdam/single/direct_connection_standalone.yml +1 -1
  309. data/spec/support/sdam/single/not_ok_response.yml +0 -1
  310. data/spec/support/server_discovery_and_monitoring.rb +3 -1
  311. data/spec/support/server_selection.rb +3 -1
  312. data/spec/support/shared/bulk_write.rb +192 -0
  313. data/spec/support/shared/protocol.rb +5 -5
  314. data/spec/support/shared/server_selector.rb +78 -13
  315. data/spec/support/travis.rb +1 -1
  316. data.tar.gz.sig +0 -0
  317. metadata +211 -72
  318. metadata.gz.sig +0 -0
  319. data/lib/mongo/bulk_write/bulk_writable.rb +0 -252
  320. data/lib/mongo/bulk_write/deletable.rb +0 -57
  321. data/lib/mongo/bulk_write/insertable.rb +0 -49
  322. data/lib/mongo/bulk_write/replacable.rb +0 -58
  323. data/lib/mongo/bulk_write/updatable.rb +0 -69
  324. data/lib/mongo/grid/fs.rb +0 -146
  325. data/lib/mongo/operation/aggregate/result.rb +0 -103
  326. data/lib/mongo/operation/aggregate.rb +0 -108
  327. data/lib/mongo/operation/command.rb +0 -61
  328. data/lib/mongo/operation/map_reduce/result.rb +0 -122
  329. data/lib/mongo/operation/map_reduce.rb +0 -95
  330. data/lib/mongo/operation/parallel_scan/result.rb +0 -72
  331. data/lib/mongo/operation/parallel_scan.rb +0 -76
  332. data/lib/mongo/operation/write/bulk/bulk_delete/result.rb +0 -75
  333. data/lib/mongo/operation/write/bulk/bulk_delete.rb +0 -145
  334. data/lib/mongo/operation/write/bulk/bulk_insert/result.rb +0 -130
  335. data/lib/mongo/operation/write/bulk/bulk_insert.rb +0 -132
  336. data/lib/mongo/operation/write/bulk/bulk_mergable.rb +0 -67
  337. data/lib/mongo/operation/write/bulk/bulk_update/result.rb +0 -174
  338. data/lib/mongo/operation/write/bulk/bulk_update.rb +0 -154
  339. data/lib/mongo/operation/write/bulk/legacy_bulk_mergable.rb +0 -83
  340. data/spec/mongo/grid/fs_spec.rb +0 -160
  341. data/spec/mongo/loggable_spec.rb +0 -63
  342. data/spec/mongo/operation/aggregate_spec.rb +0 -127
@@ -8,80 +8,60 @@ describe 'Server Selection moving average round trip time calculation' do
8
8
 
9
9
  spec = Mongo::ServerSelection::RTT::Spec.new(file)
10
10
 
11
- before(:all) do
12
-
13
- module Mongo
14
- class Server
15
-
16
- # We monkey-patch the monitor here, so the last average rtt can be controlled.
17
- # We keep the API of Monitor#initialize but add in an extra option and set the last rtt.
18
- #
19
- # @since 2.0.0
20
- class Monitor
21
-
22
- def initialize(address, listeners, options = {})
23
- @description = Mongo::Server::Description.new(address, {})
24
- @inspector = Mongo::Server::Description::Inspector.new(listeners)
25
- @options = options.freeze
26
- @connection = Connection.new(address, options)
27
- @last_round_trip_time = options[:avg_rtt_ms]
28
- @mutex = Mutex.new
29
- end
11
+ context(spec.description) do
30
12
 
31
- private
13
+ before(:all) do
32
14
 
33
- # We monkey patch this method to use an instance variable instead of calculating time elapsed.
15
+ module Mongo
16
+ class Server
17
+
18
+ # We monkey-patch the monitor here, so the last average rtt can be controlled.
19
+ # We keep the API of Monitor#initialize but add in an extra option and set the last rtt.
34
20
  #
35
21
  # @since 2.0.0
36
- def average_round_trip_time(start)
37
- new_rtt = @new_rtt_ms
38
- RTT_WEIGHT_FACTOR * new_rtt + (1 - RTT_WEIGHT_FACTOR) * (@last_round_trip_time || new_rtt)
22
+ class Monitor
23
+
24
+ alias :original_initialize :initialize
25
+ def initialize(address, listeners, options = {})
26
+ @description = Mongo::Server::Description.new(address, {})
27
+ @inspector = Mongo::Server::Description::Inspector.new(listeners)
28
+ @options = options.freeze
29
+ @connection = Connection.new(address, options)
30
+ @last_round_trip_time = options[:avg_rtt_ms]
31
+ @mutex = Mutex.new
32
+ end
33
+
34
+ # We monkey patch this method to use an instance variable instead of calculating time elapsed.
35
+ #
36
+ # @since 2.0.0
37
+ alias :original_average_round_trip_time :average_round_trip_time
38
+ def average_round_trip_time(start)
39
+ new_rtt = @new_rtt_ms
40
+ RTT_WEIGHT_FACTOR * new_rtt + (1 - RTT_WEIGHT_FACTOR) * (@last_round_trip_time || new_rtt)
41
+ end
39
42
  end
40
43
  end
41
44
  end
42
45
  end
43
- end
44
46
 
45
- after(:all) do
47
+ after(:all) do
46
48
 
47
- module Mongo
48
- class Server
49
+ module Mongo
50
+ class Server
49
51
 
50
- # Return the monitor implementation to its original for the other
51
- # tests in the suite.
52
- class Monitor
52
+ # Return the monitor implementation to its original for the other
53
+ # tests in the suite.
54
+ class Monitor
53
55
 
54
- # Create the new server monitor.
55
- #
56
- # @example Create the server monitor.
57
- # Mongo::Server::Monitor.new(address, listeners)
58
- #
59
- # @param [ Address ] address The address to monitor.
60
- # @param [ Event::Listeners ] listeners The event listeners.
61
- # @param [ Hash ] options The options.
62
- #
63
- # @since 2.0.0
64
- def initialize(address, listeners, options = {})
65
- @description = Description.new(address, {})
66
- @inspector = Description::Inspector.new(listeners)
67
- @options = options.freeze
68
- @connection = Connection.new(address, options)
69
- @last_round_trip_time = nil
70
- @mutex = Mutex.new
71
- end
72
-
73
- private
56
+ alias :initialize :original_initialize
57
+ remove_method(:original_initialize)
74
58
 
75
- def average_round_trip_time(start)
76
- new_rtt = Time.now - start
77
- RTT_WEIGHT_FACTOR * new_rtt + (1 - RTT_WEIGHT_FACTOR) * (@last_round_trip_time || new_rtt)
59
+ alias :average_round_trip_time :original_average_round_trip_time
60
+ remove_method(:original_average_round_trip_time)
78
61
  end
79
62
  end
80
63
  end
81
64
  end
82
- end
83
-
84
- context(spec.description) do
85
65
 
86
66
  let(:address) do
87
67
  Mongo::Address.new('127.0.0.1:27017')
@@ -39,6 +39,7 @@ describe 'Server Selection' do
39
39
  allow(s).to receive(:tags).and_return(server['tags'])
40
40
  allow(s).to receive(:secondary?).and_return(server['type'] == 'RSSecondary')
41
41
  allow(s).to receive(:primary?).and_return(server['type'] == 'RSPrimary')
42
+ allow(s).to receive(:connectable?).and_return(true)
42
43
  end
43
44
  end
44
45
  end
@@ -49,14 +50,15 @@ describe 'Server Selection' do
49
50
  Mongo::Server.new(address, double('cluster'), monitoring, listeners, TEST_OPTIONS).tap do |s|
50
51
  allow(s).to receive(:average_round_trip_time).and_return(server['avg_rtt_ms'])
51
52
  allow(s).to receive(:tags).and_return(server['tags'])
53
+ allow(s).to receive(:connectable?).and_return(true)
52
54
  end
53
55
  end
54
56
  end
55
57
 
56
58
  let(:server_selector) do
57
- Mongo::ServerSelector.get({ :mode => spec.read_preference['mode'],
58
- :tag_sets => spec.read_preference['tag_sets'] },
59
- :server_selection_timeout => 1)
59
+ Mongo::ServerSelector.get(:mode => spec.read_preference['mode'],
60
+ :tag_sets => spec.read_preference['tag_sets'],
61
+ :server_selection_timeout => 1)
60
62
  end
61
63
 
62
64
  before do
@@ -2,30 +2,38 @@ require 'spec_helper'
2
2
 
3
3
  describe Mongo::ServerSelector::Nearest do
4
4
 
5
+ let(:name) { :nearest }
6
+
5
7
  include_context 'server selector'
6
8
 
7
- it_behaves_like 'a read preference mode' do
8
- let(:name) { :nearest }
9
+ it_behaves_like 'a server selector mode' do
9
10
  let(:slave_ok) { true }
10
11
  end
11
12
 
12
- it_behaves_like 'a read preference mode accepting tag sets'
13
+ it_behaves_like 'a server selector accepting tag sets'
14
+ it_behaves_like 'a server selector with sensitive data in its options'
13
15
 
14
16
  describe '#to_mongos' do
15
17
 
16
18
  context 'tag set not provided' do
19
+
20
+ let(:expected) do
21
+ { :mode => 'nearest' }
22
+ end
23
+
17
24
  it 'returns a read preference formatted for mongos' do
18
- expect(read_pref.to_mongos).to eq({ :mode => 'nearest' })
25
+ expect(selector.to_mongos).to eq(expected)
19
26
  end
20
27
  end
21
28
 
22
29
  context 'tag set provided' do
30
+
23
31
  let(:tag_sets) do
24
32
  [tag_set]
25
33
  end
26
34
 
27
35
  it 'returns a read preference formatted for mongos' do
28
- expect(read_pref.to_mongos).to eq(
36
+ expect(selector.to_mongos).to eq(
29
37
  { :mode => 'nearest', :tags => tag_sets }
30
38
  )
31
39
  end
@@ -38,7 +46,7 @@ describe Mongo::ServerSelector::Nearest do
38
46
  let(:candidates) { [] }
39
47
 
40
48
  it 'returns an empty array' do
41
- expect(read_pref.send(:select, candidates)).to be_empty
49
+ expect(selector.send(:select, candidates)).to be_empty
42
50
  end
43
51
  end
44
52
 
@@ -46,7 +54,7 @@ describe Mongo::ServerSelector::Nearest do
46
54
  let(:candidates) { [primary] }
47
55
 
48
56
  it 'returns an array with the primary' do
49
- expect(read_pref.send(:select, candidates)).to eq([primary])
57
+ expect(selector.send(:select, candidates)).to eq([primary])
50
58
  end
51
59
  end
52
60
 
@@ -54,7 +62,7 @@ describe Mongo::ServerSelector::Nearest do
54
62
  let(:candidates) { [secondary] }
55
63
 
56
64
  it 'returns an array with the secondary' do
57
- expect(read_pref.send(:select, candidates)).to eq([secondary])
65
+ expect(selector.send(:select, candidates)).to eq([secondary])
58
66
  end
59
67
  end
60
68
 
@@ -62,7 +70,7 @@ describe Mongo::ServerSelector::Nearest do
62
70
  let(:candidates) { [primary, secondary] }
63
71
 
64
72
  it 'returns an array with the primary and secondary' do
65
- expect(read_pref.send(:select, candidates)).to match_array([primary, secondary])
73
+ expect(selector.send(:select, candidates)).to match_array([primary, secondary])
66
74
  end
67
75
  end
68
76
 
@@ -70,7 +78,7 @@ describe Mongo::ServerSelector::Nearest do
70
78
  let(:candidates) { [secondary, secondary] }
71
79
 
72
80
  it 'returns an array with the secondaries' do
73
- expect(read_pref.send(:select, candidates)).to match_array([secondary, secondary])
81
+ expect(selector.send(:select, candidates)).to match_array([secondary, secondary])
74
82
  end
75
83
  end
76
84
 
@@ -89,7 +97,7 @@ describe Mongo::ServerSelector::Nearest do
89
97
  let(:candidates) { [primary] }
90
98
 
91
99
  it 'returns an empty array' do
92
- expect(read_pref.send(:select, candidates)).to be_empty
100
+ expect(selector.send(:select, candidates)).to be_empty
93
101
  end
94
102
  end
95
103
 
@@ -97,7 +105,7 @@ describe Mongo::ServerSelector::Nearest do
97
105
  let(:candidates) { [matching_primary] }
98
106
 
99
107
  it 'returns an array with the primary' do
100
- expect(read_pref.send(:select, candidates)).to eq([matching_primary])
108
+ expect(selector.send(:select, candidates)).to eq([matching_primary])
101
109
  end
102
110
  end
103
111
 
@@ -105,7 +113,7 @@ describe Mongo::ServerSelector::Nearest do
105
113
  let(:candidates) { [secondary] }
106
114
 
107
115
  it 'returns an empty array' do
108
- expect(read_pref.send(:select, candidates)).to be_empty
116
+ expect(selector.send(:select, candidates)).to be_empty
109
117
  end
110
118
  end
111
119
 
@@ -113,7 +121,7 @@ describe Mongo::ServerSelector::Nearest do
113
121
  let(:candidates) { [matching_secondary] }
114
122
 
115
123
  it 'returns an array with the matching secondary' do
116
- expect(read_pref.send(:select, candidates)).to eq([matching_secondary])
124
+ expect(selector.send(:select, candidates)).to eq([matching_secondary])
117
125
  end
118
126
  end
119
127
  end
@@ -124,7 +132,7 @@ describe Mongo::ServerSelector::Nearest do
124
132
  let(:candidates) { [primary, secondary, secondary] }
125
133
 
126
134
  it 'returns an empty array' do
127
- expect(read_pref.send(:select, candidates)).to be_empty
135
+ expect(selector.send(:select, candidates)).to be_empty
128
136
  end
129
137
  end
130
138
 
@@ -132,7 +140,7 @@ describe Mongo::ServerSelector::Nearest do
132
140
  let(:candidates) { [matching_primary, secondary, secondary] }
133
141
 
134
142
  it 'returns an array with the matching primary' do
135
- expect(read_pref.send(:select, candidates)).to eq([matching_primary])
143
+ expect(selector.send(:select, candidates)).to eq([matching_primary])
136
144
  end
137
145
  end
138
146
 
@@ -140,7 +148,7 @@ describe Mongo::ServerSelector::Nearest do
140
148
  let(:candidates) { [primary, matching_secondary, secondary] }
141
149
 
142
150
  it 'returns an array with the matching secondary' do
143
- expect(read_pref.send(:select, candidates)).to eq([matching_secondary])
151
+ expect(selector.send(:select, candidates)).to eq([matching_secondary])
144
152
  end
145
153
  end
146
154
 
@@ -149,7 +157,7 @@ describe Mongo::ServerSelector::Nearest do
149
157
  let(:expected) { [matching_secondary, matching_secondary] }
150
158
 
151
159
  it 'returns an array with the matching secondaries' do
152
- expect(read_pref.send(:select, candidates)).to eq(expected)
160
+ expect(selector.send(:select, candidates)).to eq(expected)
153
161
  end
154
162
  end
155
163
 
@@ -158,7 +166,7 @@ describe Mongo::ServerSelector::Nearest do
158
166
  let(:expected) { [matching_primary, matching_secondary] }
159
167
 
160
168
  it 'returns an array with the matching primary and secondary' do
161
- expect(read_pref.send(:select, candidates)).to match_array(expected)
169
+ expect(selector.send(:select, candidates)).to match_array(expected)
162
170
  end
163
171
  end
164
172
  end
@@ -174,7 +182,7 @@ describe Mongo::ServerSelector::Nearest do
174
182
  let(:candidates) { [far_primary] }
175
183
 
176
184
  it 'returns array with far primary' do
177
- expect(read_pref.send(:select, candidates)).to eq([far_primary])
185
+ expect(selector.send(:select, candidates)).to eq([far_primary])
178
186
  end
179
187
  end
180
188
 
@@ -182,7 +190,7 @@ describe Mongo::ServerSelector::Nearest do
182
190
  let(:candidates) { [far_secondary] }
183
191
 
184
192
  it 'returns array with far primary' do
185
- expect(read_pref.send(:select, candidates)).to eq([far_secondary])
193
+ expect(selector.send(:select, candidates)).to eq([far_secondary])
186
194
  end
187
195
  end
188
196
  end
@@ -193,7 +201,7 @@ describe Mongo::ServerSelector::Nearest do
193
201
  let(:candidates) { [primary, secondary] }
194
202
 
195
203
  it 'returns array with primary and secondary' do
196
- expect(read_pref.send(:select, candidates)).to match_array(
204
+ expect(selector.send(:select, candidates)).to match_array(
197
205
  [primary, secondary]
198
206
  )
199
207
  end
@@ -203,7 +211,7 @@ describe Mongo::ServerSelector::Nearest do
203
211
  let(:candidates) { [primary, far_secondary] }
204
212
 
205
213
  it 'returns array with local primary' do
206
- expect(read_pref.send(:select, candidates)).to eq([primary])
214
+ expect(selector.send(:select, candidates)).to eq([primary])
207
215
  end
208
216
  end
209
217
 
@@ -211,7 +219,7 @@ describe Mongo::ServerSelector::Nearest do
211
219
  let(:candidates) { [far_primary, secondary] }
212
220
 
213
221
  it 'returns array with local secondary' do
214
- expect(read_pref.send(:select, candidates)).to eq([secondary])
222
+ expect(selector.send(:select, candidates)).to eq([secondary])
215
223
  end
216
224
  end
217
225
 
@@ -220,7 +228,7 @@ describe Mongo::ServerSelector::Nearest do
220
228
  let(:expected) { [far_primary, far_secondary] }
221
229
 
222
230
  it 'returns array with both servers' do
223
- expect(read_pref.send(:select, candidates)).to match_array(expected)
231
+ expect(selector.send(:select, candidates)).to match_array(expected)
224
232
  end
225
233
  end
226
234
 
@@ -231,7 +239,7 @@ describe Mongo::ServerSelector::Nearest do
231
239
  let(:expected) { [primary, secondary] }
232
240
 
233
241
  it 'returns array with local primary and local secondary' do
234
- expect(read_pref.send(:select, candidates)).to match_array(expected)
242
+ expect(selector.send(:select, candidates)).to match_array(expected)
235
243
  end
236
244
  end
237
245
 
@@ -240,7 +248,7 @@ describe Mongo::ServerSelector::Nearest do
240
248
  let(:expected) { [secondary, secondary] }
241
249
 
242
250
  it 'returns array with the two local secondaries' do
243
- expect(read_pref.send(:select, candidates)).to match_array(expected)
251
+ expect(selector.send(:select, candidates)).to match_array(expected)
244
252
  end
245
253
  end
246
254
  end
@@ -2,21 +2,23 @@ require 'spec_helper'
2
2
 
3
3
  describe Mongo::ServerSelector::PrimaryPreferred do
4
4
 
5
+ let(:name) { :primary_preferred }
6
+
5
7
  include_context 'server selector'
6
8
 
7
- it_behaves_like 'a read preference mode' do
8
- let(:name) { :primary_preferred }
9
+ it_behaves_like 'a server selector mode' do
9
10
  let(:slave_ok) { true }
10
11
  end
11
12
 
12
- it_behaves_like 'a read preference mode accepting tag sets'
13
+ it_behaves_like 'a server selector accepting tag sets'
14
+ it_behaves_like 'a server selector with sensitive data in its options'
13
15
 
14
16
  describe '#to_mongos' do
15
17
 
16
18
  context 'tag sets not provided' do
17
19
 
18
20
  it 'returns a read preference formatted for mongos' do
19
- expect(read_pref.to_mongos).to eq({ :mode => 'primaryPreferred' })
21
+ expect(selector.to_mongos).to eq({ :mode => 'primaryPreferred' })
20
22
  end
21
23
  end
22
24
 
@@ -24,7 +26,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
24
26
  let(:tag_sets) { [tag_set] }
25
27
 
26
28
  it 'returns a read preference formatted for mongos' do
27
- expect(read_pref.to_mongos).to eq(
29
+ expect(selector.to_mongos).to eq(
28
30
  { :mode => 'primaryPreferred', :tags => tag_sets}
29
31
  )
30
32
  end
@@ -37,7 +39,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
37
39
  let(:candidates) { [] }
38
40
 
39
41
  it 'returns an empty array' do
40
- expect(read_pref.send(:select, candidates)).to be_empty
42
+ expect(selector.send(:select, candidates)).to be_empty
41
43
  end
42
44
  end
43
45
 
@@ -45,7 +47,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
45
47
  let(:candidates) { [primary] }
46
48
 
47
49
  it 'returns an array with the primary' do
48
- expect(read_pref.send(:select, candidates)).to eq( [primary] )
50
+ expect(selector.send(:select, candidates)).to eq( [primary] )
49
51
  end
50
52
  end
51
53
 
@@ -53,7 +55,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
53
55
  let(:candidates) { [secondary] }
54
56
 
55
57
  it 'returns an array with the secondary' do
56
- expect(read_pref.send(:select, candidates)).to eq( [secondary] )
58
+ expect(selector.send(:select, candidates)).to eq( [secondary] )
57
59
  end
58
60
  end
59
61
 
@@ -62,7 +64,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
62
64
  let(:expected) { [primary] }
63
65
 
64
66
  it 'returns an array with the primary' do
65
- expect(read_pref.send(:select, candidates)).to eq(expected)
67
+ expect(selector.send(:select, candidates)).to eq(expected)
66
68
  end
67
69
  end
68
70
 
@@ -71,7 +73,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
71
73
  let(:expected) { [primary] }
72
74
 
73
75
  it 'returns an array with the primary' do
74
- expect(read_pref.send(:select, candidates)).to eq(expected)
76
+ expect(selector.send(:select, candidates)).to eq(expected)
75
77
  end
76
78
  end
77
79
 
@@ -92,7 +94,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
92
94
  let(:candidates) { [primary] }
93
95
 
94
96
  it 'returns array with primary' do
95
- expect(read_pref.send(:select, candidates)).to eq([primary])
97
+ expect(selector.send(:select, candidates)).to eq([primary])
96
98
  end
97
99
  end
98
100
 
@@ -100,7 +102,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
100
102
  let(:candidates) { [matching_primary] }
101
103
 
102
104
  it 'returns array with matching primary' do
103
- expect(read_pref.send(:select, candidates)).to eq([matching_primary])
105
+ expect(selector.send(:select, candidates)).to eq([matching_primary])
104
106
  end
105
107
  end
106
108
 
@@ -108,7 +110,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
108
110
  let(:candidates) { [matching_secondary] }
109
111
 
110
112
  it 'returns array with matching secondary' do
111
- expect(read_pref.send(:select, candidates)).to eq([matching_secondary])
113
+ expect(selector.send(:select, candidates)).to eq([matching_secondary])
112
114
  end
113
115
  end
114
116
 
@@ -116,7 +118,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
116
118
  let(:candidates) { [secondary] }
117
119
 
118
120
  it 'returns an empty array' do
119
- expect(read_pref.send(:select, candidates)).to be_empty
121
+ expect(selector.send(:select, candidates)).to be_empty
120
122
  end
121
123
  end
122
124
  end
@@ -127,7 +129,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
127
129
  let(:candidates) { [primary, secondary, secondary] }
128
130
 
129
131
  it 'returns an array with the primary' do
130
- expect(read_pref.send(:select, candidates)).to eq([primary])
132
+ expect(selector.send(:select, candidates)).to eq([primary])
131
133
  end
132
134
  end
133
135
 
@@ -135,7 +137,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
135
137
  let(:candidates) { [matching_primary, secondary, secondary] }
136
138
 
137
139
  it 'returns an array of the primary' do
138
- expect(read_pref.send(:select, candidates)).to eq([matching_primary])
140
+ expect(selector.send(:select, candidates)).to eq([matching_primary])
139
141
  end
140
142
  end
141
143
 
@@ -144,7 +146,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
144
146
  let(:expected) { [primary] }
145
147
 
146
148
  it 'returns an array of the primary' do
147
- expect(read_pref.send(:select, candidates)).to eq(expected)
149
+ expect(selector.send(:select, candidates)).to eq(expected)
148
150
  end
149
151
  end
150
152
 
@@ -153,7 +155,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
153
155
  let(:expected) { [primary] }
154
156
 
155
157
  it 'returns an array of the primary ' do
156
- expect(read_pref.send(:select, candidates)).to eq(expected)
158
+ expect(selector.send(:select, candidates)).to eq(expected)
157
159
  end
158
160
  end
159
161
 
@@ -162,7 +164,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
162
164
  let(:expected) { [primary] }
163
165
 
164
166
  it 'returns an array of the primary' do
165
- expect(read_pref.send(:select, candidates)).to eq(expected)
167
+ expect(selector.send(:select, candidates)).to eq(expected)
166
168
  end
167
169
  end
168
170
  end
@@ -178,7 +180,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
178
180
  let(:candidates) { [far_primary] }
179
181
 
180
182
  it 'returns array with far primary' do
181
- expect(read_pref.send(:select, candidates)).to eq([far_primary])
183
+ expect(selector.send(:select, candidates)).to eq([far_primary])
182
184
  end
183
185
  end
184
186
 
@@ -186,7 +188,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
186
188
  let(:candidates) { [far_secondary] }
187
189
 
188
190
  it 'returns array with far primary' do
189
- expect(read_pref.send(:select, candidates)).to eq([far_secondary])
191
+ expect(selector.send(:select, candidates)).to eq([far_secondary])
190
192
  end
191
193
 
192
194
  end
@@ -201,7 +203,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
201
203
  let(:expected) { [primary] }
202
204
 
203
205
  it 'returns an array of the primary' do
204
- expect(read_pref.send(:select, candidates)).to eq(expected)
206
+ expect(selector.send(:select, candidates)).to eq(expected)
205
207
  end
206
208
  end
207
209
 
@@ -210,7 +212,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
210
212
  let(:expected) { [primary] }
211
213
 
212
214
  it 'returns an array of the primary' do
213
- expect(read_pref.send(:select, candidates)).to eq(expected)
215
+ expect(selector.send(:select, candidates)).to eq(expected)
214
216
  end
215
217
  end
216
218
 
@@ -219,7 +221,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
219
221
  let(:expected) { [far_primary] }
220
222
 
221
223
  it 'returns an array of the far primary' do
222
- expect(read_pref.send(:select, candidates)).to eq(expected)
224
+ expect(selector.send(:select, candidates)).to eq(expected)
223
225
  end
224
226
  end
225
227
 
@@ -228,7 +230,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
228
230
  let(:expected) { [far_primary] }
229
231
 
230
232
  it 'returns an array of the far primary' do
231
- expect(read_pref.send(:select, candidates)).to eq(expected)
233
+ expect(selector.send(:select, candidates)).to eq(expected)
232
234
  end
233
235
  end
234
236
 
@@ -239,7 +241,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
239
241
  let(:expected) { [primary] }
240
242
 
241
243
  it 'returns an array of the primary' do
242
- expect(read_pref.send(:select, candidates)).to eq(expected)
244
+ expect(selector.send(:select, candidates)).to eq(expected)
243
245
  end
244
246
  end
245
247
 
@@ -248,7 +250,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
248
250
  let(:expected) { [far_primary] }
249
251
 
250
252
  it 'returns an array with primary' do
251
- expect(read_pref.send(:select, candidates)).to eq(expected)
253
+ expect(selector.send(:select, candidates)).to eq(expected)
252
254
  end
253
255
  end
254
256
  end
@@ -261,7 +263,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
261
263
  let(:expected) { [secondary] }
262
264
 
263
265
  it 'returns an array with the secondary' do
264
- expect(read_pref.send(:select, candidates)).to eq(expected)
266
+ expect(selector.send(:select, candidates)).to eq(expected)
265
267
  end
266
268
  end
267
269
 
@@ -270,7 +272,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
270
272
  let(:expected) { [secondary] }
271
273
 
272
274
  it 'returns an array of the secondary' do
273
- expect(read_pref.send(:select, candidates)).to eq(expected)
275
+ expect(selector.send(:select, candidates)).to eq(expected)
274
276
  end
275
277
  end
276
278
 
@@ -279,7 +281,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
279
281
  let(:expected) { [secondary, secondary] }
280
282
 
281
283
  it 'returns an array of the secondary' do
282
- expect(read_pref.send(:select, candidates)).to eq(expected)
284
+ expect(selector.send(:select, candidates)).to eq(expected)
283
285
  end
284
286
  end
285
287
  end