mongo 2.0.6 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (317) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +5 -2
  3. data/lib/mongo/address/ipv4.rb +6 -1
  4. data/lib/mongo/address/unix.rb +2 -2
  5. data/lib/mongo/address.rb +18 -10
  6. data/lib/mongo/auth/cr/conversation.rb +1 -1
  7. data/lib/mongo/auth/ldap/conversation.rb +7 -3
  8. data/lib/mongo/auth/scram/conversation.rb +9 -3
  9. data/lib/mongo/auth/user/view.rb +23 -2
  10. data/lib/mongo/auth/x509/conversation.rb +1 -1
  11. data/lib/mongo/bulk_write/combineable.rb +51 -0
  12. data/lib/mongo/bulk_write/ordered_combiner.rb +55 -0
  13. data/lib/mongo/bulk_write/result.rb +191 -0
  14. data/lib/mongo/bulk_write/result_combiner.rb +117 -0
  15. data/lib/mongo/bulk_write/transformable.rb +132 -0
  16. data/lib/mongo/bulk_write/unordered_combiner.rb +52 -0
  17. data/lib/mongo/bulk_write/validatable.rb +62 -0
  18. data/lib/mongo/bulk_write.rb +159 -23
  19. data/lib/mongo/client.rb +52 -16
  20. data/lib/mongo/cluster/topology/replica_set.rb +27 -9
  21. data/lib/mongo/cluster/topology/sharded.rb +1 -1
  22. data/lib/mongo/cluster/topology/unknown.rb +5 -2
  23. data/lib/mongo/cluster.rb +42 -7
  24. data/lib/mongo/collection/view/aggregation.rb +48 -9
  25. data/lib/mongo/collection/view/immutable.rb +6 -6
  26. data/lib/mongo/collection/view/iterable.rb +18 -4
  27. data/lib/mongo/collection/view/map_reduce.rb +58 -17
  28. data/lib/mongo/collection/view/readable.rb +173 -42
  29. data/lib/mongo/collection/view/writable.rb +37 -23
  30. data/lib/mongo/collection/view.rb +2 -2
  31. data/lib/mongo/collection.rb +370 -33
  32. data/lib/mongo/cursor.rb +15 -3
  33. data/lib/mongo/database/view.rb +5 -4
  34. data/lib/mongo/database.rb +14 -4
  35. data/lib/mongo/dbref.rb +113 -0
  36. data/lib/mongo/error/closed_stream.rb +34 -0
  37. data/lib/mongo/error/extra_file_chunk.rb +34 -0
  38. data/lib/mongo/error/{invalid_uri_option.rb → file_not_found.rb} +11 -12
  39. data/lib/mongo/error/invalid_file.rb +2 -2
  40. data/lib/mongo/error/invalid_file_revision.rb +37 -0
  41. data/lib/mongo/error/invalid_uri.rb +5 -4
  42. data/lib/mongo/error/missing_file_chunk.rb +38 -0
  43. data/lib/mongo/error/operation_failure.rb +1 -1
  44. data/lib/mongo/error/parser.rb +1 -1
  45. data/lib/mongo/error/unchangeable_collection_option.rb +38 -0
  46. data/lib/mongo/error/unexpected_chunk_length.rb +39 -0
  47. data/lib/mongo/error.rb +13 -2
  48. data/lib/mongo/event/description_changed.rb +1 -1
  49. data/lib/mongo/grid/file/chunk.rb +6 -6
  50. data/lib/mongo/grid/file/{metadata.rb → info.rb} +41 -39
  51. data/lib/mongo/grid/file.rb +13 -10
  52. data/lib/mongo/grid/fs_bucket.rb +448 -0
  53. data/lib/mongo/grid/stream/read.rb +208 -0
  54. data/lib/mongo/grid/stream/write.rb +187 -0
  55. data/lib/mongo/grid/stream.rb +64 -0
  56. data/lib/mongo/grid.rb +2 -1
  57. data/lib/mongo/index/view.rb +3 -3
  58. data/lib/mongo/index.rb +5 -0
  59. data/lib/mongo/loggable.rb +34 -57
  60. data/lib/mongo/logger.rb +16 -78
  61. data/lib/mongo/monitoring/command_log_subscriber.rb +112 -0
  62. data/lib/mongo/monitoring/event/command_failed.rb +96 -0
  63. data/lib/mongo/monitoring/event/command_started.rb +89 -0
  64. data/lib/mongo/monitoring/event/command_succeeded.rb +118 -0
  65. data/lib/mongo/monitoring/event/secure.rb +58 -0
  66. data/lib/mongo/monitoring/event.rb +18 -0
  67. data/lib/mongo/monitoring/publishable.rb +106 -0
  68. data/lib/mongo/monitoring.rb +195 -0
  69. data/lib/mongo/operation/{aggregate.rb → commands/aggregate.rb} +3 -41
  70. data/lib/mongo/operation/commands/collections_info/result.rb +39 -0
  71. data/lib/mongo/operation/commands/collections_info.rb +68 -0
  72. data/lib/mongo/operation/{command.rb → commands/command.rb} +2 -18
  73. data/lib/mongo/operation/commands/indexes.rb +70 -0
  74. data/lib/mongo/operation/commands/list_collections/result.rb +112 -0
  75. data/lib/mongo/operation/commands/list_collections.rb +54 -0
  76. data/lib/mongo/operation/commands/list_indexes/result.rb +116 -0
  77. data/lib/mongo/operation/commands/list_indexes.rb +56 -0
  78. data/lib/mongo/operation/{map_reduce → commands/map_reduce}/result.rb +1 -1
  79. data/lib/mongo/operation/{map_reduce.rb → commands/map_reduce.rb} +3 -41
  80. data/lib/mongo/operation/commands/parallel_scan/result.rb +72 -0
  81. data/lib/mongo/operation/commands/parallel_scan.rb +56 -0
  82. data/lib/mongo/operation/commands/user_query.rb +69 -0
  83. data/lib/mongo/{bulk_write/ordered_bulk_write.rb → operation/commands/users_info/result.rb} +18 -30
  84. data/lib/mongo/operation/commands/users_info.rb +53 -0
  85. data/lib/mongo/operation/commands.rb +24 -0
  86. data/lib/mongo/operation/executable.rb +4 -68
  87. data/lib/mongo/operation/kill_cursors.rb +3 -3
  88. data/lib/mongo/operation/read/get_more.rb +2 -22
  89. data/lib/mongo/{bulk_write/unordered_bulk_write.rb → operation/read/query/result.rb} +20 -26
  90. data/lib/mongo/operation/read/query.rb +4 -21
  91. data/lib/mongo/operation/read.rb +0 -4
  92. data/lib/mongo/operation/{read_preferrable.rb → read_preference.rb} +3 -2
  93. data/lib/mongo/operation/result.rb +13 -1
  94. data/lib/mongo/operation/specifiable.rb +42 -0
  95. data/lib/mongo/operation/write/bulk/bulkable.rb +82 -0
  96. data/lib/mongo/operation/write/bulk/delete/result.rb +74 -0
  97. data/lib/mongo/operation/write/bulk/delete.rb +71 -0
  98. data/lib/mongo/operation/write/bulk/insert/result.rb +129 -0
  99. data/lib/mongo/operation/write/bulk/insert.rb +96 -0
  100. data/lib/mongo/operation/write/bulk/legacy_mergable.rb +87 -0
  101. data/lib/mongo/operation/write/bulk/mergable.rb +71 -0
  102. data/lib/mongo/operation/write/bulk/update/result.rb +174 -0
  103. data/lib/mongo/operation/write/bulk/update.rb +81 -0
  104. data/lib/mongo/operation/write/bulk.rb +6 -3
  105. data/lib/mongo/operation/write/command/create_index.rb +0 -1
  106. data/lib/mongo/operation/write/command/create_user.rb +0 -1
  107. data/lib/mongo/operation/write/command/delete.rb +0 -1
  108. data/lib/mongo/operation/write/command/drop_index.rb +0 -1
  109. data/lib/mongo/operation/write/command/insert.rb +0 -1
  110. data/lib/mongo/operation/write/command/remove_user.rb +0 -1
  111. data/lib/mongo/operation/write/command/update.rb +0 -1
  112. data/lib/mongo/operation/write/command/update_user.rb +0 -1
  113. data/lib/mongo/operation/write/command/writable.rb +13 -18
  114. data/lib/mongo/operation/write/create_index.rb +4 -27
  115. data/lib/mongo/operation/write/create_user.rb +4 -30
  116. data/lib/mongo/operation/write/delete.rb +6 -29
  117. data/lib/mongo/operation/write/drop_index.rb +3 -3
  118. data/lib/mongo/operation/write/gle.rb +48 -0
  119. data/lib/mongo/operation/write/idable.rb +5 -0
  120. data/lib/mongo/operation/write/insert.rb +2 -24
  121. data/lib/mongo/operation/write/remove_user.rb +4 -27
  122. data/lib/mongo/operation/write/update.rb +13 -36
  123. data/lib/mongo/operation/write/update_user.rb +4 -30
  124. data/lib/mongo/operation/write/write_command_enabled.rb +53 -0
  125. data/lib/mongo/operation/write.rb +2 -0
  126. data/lib/mongo/operation.rb +32 -4
  127. data/lib/mongo/options/mapper.rb +4 -2
  128. data/lib/mongo/options/redacted.rb +156 -0
  129. data/lib/mongo/options.rb +1 -0
  130. data/lib/mongo/protocol/delete.rb +75 -15
  131. data/lib/mongo/protocol/get_more.rb +65 -13
  132. data/lib/mongo/protocol/insert.rb +85 -13
  133. data/lib/mongo/protocol/kill_cursors.rb +59 -14
  134. data/lib/mongo/protocol/message.rb +12 -12
  135. data/lib/mongo/protocol/query.rb +163 -37
  136. data/lib/mongo/protocol/reply.rb +103 -0
  137. data/lib/mongo/protocol/serializers.rb +1 -1
  138. data/lib/mongo/protocol/update.rb +82 -14
  139. data/lib/mongo/retryable.rb +83 -0
  140. data/lib/mongo/server/connectable.rb +21 -25
  141. data/lib/mongo/server/connection.rb +75 -4
  142. data/lib/mongo/server/connection_pool/queue.rb +15 -0
  143. data/lib/mongo/server/connection_pool.rb +12 -0
  144. data/lib/mongo/server/description/features.rb +2 -1
  145. data/lib/mongo/server/description.rb +52 -1
  146. data/lib/mongo/server/monitor/connection.rb +26 -2
  147. data/lib/mongo/server/monitor.rb +19 -3
  148. data/lib/mongo/server.rb +39 -5
  149. data/lib/mongo/server_selector/selectable.rb +40 -31
  150. data/lib/mongo/server_selector.rb +19 -10
  151. data/lib/mongo/socket/ssl.rb +28 -16
  152. data/lib/mongo/socket/tcp.rb +3 -3
  153. data/lib/mongo/socket/unix.rb +5 -8
  154. data/lib/mongo/socket.rb +11 -4
  155. data/lib/mongo/uri.rb +248 -137
  156. data/lib/mongo/version.rb +1 -1
  157. data/lib/mongo.rb +5 -3
  158. data/spec/mongo/address/unix_spec.rb +1 -1
  159. data/spec/mongo/address_spec.rb +25 -0
  160. data/spec/mongo/auth/cr_spec.rb +9 -1
  161. data/spec/mongo/auth/ldap/conversation_spec.rb +43 -0
  162. data/spec/mongo/auth/ldap_spec.rb +9 -1
  163. data/spec/mongo/auth/scram_spec.rb +9 -1
  164. data/spec/mongo/auth/user/view_spec.rb +26 -1
  165. data/spec/mongo/auth/x509_spec.rb +9 -1
  166. data/spec/mongo/bulk_write/ordered_combiner_spec.rb +271 -0
  167. data/spec/mongo/bulk_write/unordered_combiner_spec.rb +239 -0
  168. data/spec/mongo/bulk_write_spec.rb +428 -0
  169. data/spec/mongo/client_spec.rb +167 -17
  170. data/spec/mongo/cluster/topology/replica_set_spec.rb +18 -9
  171. data/spec/mongo/cluster/topology/sharded_spec.rb +11 -3
  172. data/spec/mongo/cluster/topology/single_spec.rb +12 -4
  173. data/spec/mongo/cluster_spec.rb +55 -10
  174. data/spec/mongo/collection/view/aggregation_spec.rb +188 -1
  175. data/spec/mongo/collection/view/explainable_spec.rb +1 -1
  176. data/spec/mongo/collection/view/immutable_spec.rb +103 -0
  177. data/spec/mongo/collection/view/map_reduce_spec.rb +99 -4
  178. data/spec/mongo/collection/view/readable_spec.rb +238 -6
  179. data/spec/mongo/collection/view/writable_spec.rb +4 -4
  180. data/spec/mongo/collection/view_spec.rb +459 -71
  181. data/spec/mongo/collection_spec.rb +1291 -9
  182. data/spec/mongo/command_monitoring_spec.rb +51 -0
  183. data/spec/mongo/connection_string_spec.rb +115 -0
  184. data/spec/mongo/crud_spec.rb +2 -2
  185. data/spec/mongo/cursor_spec.rb +3 -3
  186. data/spec/mongo/database_spec.rb +47 -11
  187. data/spec/mongo/dbref_spec.rb +149 -0
  188. data/spec/mongo/grid/file/chunk_spec.rb +5 -5
  189. data/spec/mongo/grid/file/{metadata_spec.rb → info_spec.rb} +29 -17
  190. data/spec/mongo/grid/file_spec.rb +8 -8
  191. data/spec/mongo/grid/fs_bucket_spec.rb +1020 -0
  192. data/spec/mongo/grid/stream/read_spec.rb +275 -0
  193. data/spec/mongo/grid/stream/write_spec.rb +440 -0
  194. data/spec/mongo/grid/stream_spec.rb +48 -0
  195. data/spec/mongo/gridfs_spec.rb +50 -0
  196. data/spec/mongo/logger_spec.rb +0 -40
  197. data/spec/mongo/monitoring/command_log_subscriber_spec.rb +76 -0
  198. data/spec/mongo/monitoring/event/command_started_spec.rb +26 -0
  199. data/spec/mongo/monitoring/event/command_succeeded_spec.rb +26 -0
  200. data/spec/mongo/monitoring/event/secure_spec.rb +57 -0
  201. data/spec/mongo/monitoring_spec.rb +168 -0
  202. data/spec/mongo/operation/commands/aggregate_spec.rb +69 -0
  203. data/spec/mongo/operation/{read → commands}/collections_info_spec.rb +1 -1
  204. data/spec/mongo/operation/{command_spec.rb → commands/command_spec.rb} +0 -18
  205. data/spec/mongo/operation/{read → commands}/indexes_spec.rb +1 -1
  206. data/spec/mongo/operation/{map_reduce_spec.rb → commands/map_reduce_spec.rb} +1 -19
  207. data/spec/mongo/operation/kill_cursors_spec.rb +1 -17
  208. data/spec/mongo/operation/read/get_more_spec.rb +0 -16
  209. data/spec/mongo/operation/read/query_spec.rb +19 -16
  210. data/spec/mongo/operation/{read_preferrable_spec.rb → read_preference_spec.rb} +11 -11
  211. data/spec/mongo/operation/write/bulk/{bulk_delete_spec.rb → delete_spec.rb} +18 -29
  212. data/spec/mongo/operation/write/bulk/{bulk_insert_spec.rb → insert_spec.rb} +3 -14
  213. data/spec/mongo/operation/write/bulk/{bulk_update_spec.rb → update_spec.rb} +8 -19
  214. data/spec/mongo/operation/write/command/delete_spec.rb +0 -16
  215. data/spec/mongo/operation/write/command/insert_spec.rb +0 -16
  216. data/spec/mongo/operation/write/command/update_spec.rb +0 -16
  217. data/spec/mongo/operation/write/delete_spec.rb +4 -4
  218. data/spec/mongo/operation/write/insert_spec.rb +2 -13
  219. data/spec/mongo/operation/write/update_spec.rb +7 -7
  220. data/spec/mongo/options/redacted_spec.rb +350 -0
  221. data/spec/mongo/protocol/kill_cursors_spec.rb +5 -3
  222. data/spec/mongo/protocol/query_spec.rb +15 -30
  223. data/spec/mongo/retryable_spec.rb +147 -0
  224. data/spec/mongo/server/connection_pool/queue_spec.rb +16 -0
  225. data/spec/mongo/server/connection_pool_spec.rb +50 -6
  226. data/spec/mongo/server/connection_spec.rb +49 -4
  227. data/spec/mongo/server/description_spec.rb +49 -3
  228. data/spec/mongo/server/monitor_spec.rb +51 -0
  229. data/spec/mongo/server_discovery_and_monitoring_spec.rb +32 -59
  230. data/spec/mongo/server_selection_rtt_spec.rb +37 -57
  231. data/spec/mongo/server_selection_spec.rb +19 -9
  232. data/spec/mongo/server_selector/nearest_spec.rb +35 -27
  233. data/spec/mongo/server_selector/primary_preferred_spec.rb +32 -30
  234. data/spec/mongo/server_selector/primary_spec.rb +21 -14
  235. data/spec/mongo/server_selector/secondary_preferred_spec.rb +28 -26
  236. data/spec/mongo/server_selector/secondary_spec.rb +24 -22
  237. data/spec/mongo/server_selector_spec.rb +87 -24
  238. data/spec/mongo/server_spec.rb +94 -8
  239. data/spec/mongo/socket/ssl_spec.rb +123 -13
  240. data/spec/mongo/socket/unix_spec.rb +52 -0
  241. data/spec/mongo/uri_spec.rb +295 -67
  242. data/spec/spec_helper.rb +40 -24
  243. data/spec/support/authorization.rb +23 -9
  244. data/spec/support/certificates/client.pem +4 -4
  245. data/spec/support/command_monitoring/bulkWrite.yml +73 -0
  246. data/spec/support/command_monitoring/command.yml +42 -0
  247. data/spec/support/command_monitoring/deleteMany.yml +55 -0
  248. data/spec/support/command_monitoring/deleteOne.yml +55 -0
  249. data/spec/support/command_monitoring/find.yml +219 -0
  250. data/spec/support/command_monitoring/insertMany.yml +81 -0
  251. data/spec/support/command_monitoring/insertOne.yml +51 -0
  252. data/spec/support/command_monitoring/updateMany.yml +67 -0
  253. data/spec/support/command_monitoring/updateOne.yml +95 -0
  254. data/spec/support/command_monitoring.rb +365 -0
  255. data/spec/support/connection_string.rb +228 -0
  256. data/spec/support/connection_string_tests/invalid-uris.yml +193 -0
  257. data/spec/support/connection_string_tests/valid-auth.yml +256 -0
  258. data/spec/support/connection_string_tests/valid-host_identifiers.yml +121 -0
  259. data/spec/support/connection_string_tests/valid-options.yml +30 -0
  260. data/spec/support/connection_string_tests/valid-unix_socket-absolute.yml +197 -0
  261. data/spec/support/connection_string_tests/valid-unix_socket-relative.yml +213 -0
  262. data/spec/support/connection_string_tests/valid-warnings.yml +55 -0
  263. data/spec/support/crud/read.rb +22 -19
  264. data/spec/support/crud/write.rb +58 -27
  265. data/spec/support/crud.rb +10 -2
  266. data/spec/support/gridfs.rb +637 -0
  267. data/spec/support/gridfs_tests/delete.yml +157 -0
  268. data/spec/support/gridfs_tests/download.yml +210 -0
  269. data/spec/support/gridfs_tests/download_by_name.yml +113 -0
  270. data/spec/support/gridfs_tests/upload.yml +158 -0
  271. data/spec/support/matchers.rb +1 -1
  272. data/spec/support/sdam/rs/equal_electionids.yml +44 -0
  273. data/spec/support/sdam/rs/new_primary_new_electionid.yml +95 -0
  274. data/spec/support/sdam/rs/null_election_id.yml +144 -0
  275. data/spec/support/sdam/rs/primary_disconnect_electionid.yml +124 -0
  276. data/spec/support/sdam/rs/primary_mismatched_me.yml +37 -0
  277. data/spec/support/sdam/rs/primary_to_no_primary_mismatched_me.yml +75 -0
  278. data/spec/support/sdam/rs/secondary_mismatched_me.yml +37 -0
  279. data/spec/support/sdam/sharded/mongos_disconnect.yml +104 -0
  280. data/spec/support/sdam/single/direct_connection_rsarbiter.yml +1 -1
  281. data/spec/support/sdam/single/direct_connection_rsprimary.yml +1 -1
  282. data/spec/support/sdam/single/direct_connection_rssecondary.yml +1 -1
  283. data/spec/support/sdam/single/direct_connection_slave.yml +1 -1
  284. data/spec/support/sdam/single/direct_connection_standalone.yml +1 -1
  285. data/spec/support/sdam/single/not_ok_response.yml +0 -1
  286. data/spec/support/server_discovery_and_monitoring.rb +22 -3
  287. data/spec/support/server_selection.rb +3 -1
  288. data/spec/support/shared/bulk_write.rb +218 -22
  289. data/spec/support/shared/server_selector.rb +80 -14
  290. data.tar.gz.sig +0 -0
  291. metadata +188 -59
  292. metadata.gz.sig +0 -0
  293. data/lib/mongo/bulk_write/bulk_writable.rb +0 -196
  294. data/lib/mongo/bulk_write/deletable.rb +0 -56
  295. data/lib/mongo/bulk_write/insertable.rb +0 -48
  296. data/lib/mongo/bulk_write/replacable.rb +0 -57
  297. data/lib/mongo/bulk_write/updatable.rb +0 -68
  298. data/lib/mongo/grid/fs.rb +0 -149
  299. data/lib/mongo/operation/list_collections/result.rb +0 -114
  300. data/lib/mongo/operation/list_indexes/result.rb +0 -118
  301. data/lib/mongo/operation/read/collections_info.rb +0 -68
  302. data/lib/mongo/operation/read/indexes.rb +0 -69
  303. data/lib/mongo/operation/read/list_collections.rb +0 -76
  304. data/lib/mongo/operation/read/list_indexes.rb +0 -78
  305. data/lib/mongo/operation/write/bulk/bulk_delete/result.rb +0 -75
  306. data/lib/mongo/operation/write/bulk/bulk_delete.rb +0 -145
  307. data/lib/mongo/operation/write/bulk/bulk_insert/result.rb +0 -130
  308. data/lib/mongo/operation/write/bulk/bulk_insert.rb +0 -132
  309. data/lib/mongo/operation/write/bulk/bulk_mergable.rb +0 -67
  310. data/lib/mongo/operation/write/bulk/bulk_update/result.rb +0 -162
  311. data/lib/mongo/operation/write/bulk/bulk_update.rb +0 -154
  312. data/lib/mongo/operation/write/bulk/legacy_bulk_mergable.rb +0 -83
  313. data/spec/mongo/bulk/bulk_write_spec.rb +0 -262
  314. data/spec/mongo/grid/fs_spec.rb +0 -160
  315. data/spec/mongo/loggable_spec.rb +0 -63
  316. data/spec/mongo/operation/aggregate_spec.rb +0 -127
  317. /data/lib/mongo/operation/{aggregate → commands/aggregate}/result.rb +0 -0
@@ -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
@@ -2,27 +2,34 @@ require 'spec_helper'
2
2
 
3
3
  describe Mongo::ServerSelector::Primary do
4
4
 
5
+ let(:name) { :primary }
6
+
5
7
  include_context 'server selector'
6
8
 
7
- it_behaves_like 'a read preference mode' do
8
- let(:name) { :primary }
9
+ it_behaves_like 'a server selector mode' do
9
10
  let(:slave_ok) { false }
10
11
  end
12
+ it_behaves_like 'a server selector with sensitive data in its options'
11
13
 
12
14
  describe '#tag_sets' do
13
15
 
14
16
  context 'tags not provided' do
15
17
 
16
18
  it 'returns an empty array' do
17
- expect(read_pref.tag_sets).to be_empty
19
+ expect(selector.tag_sets).to be_empty
18
20
  end
19
21
  end
20
22
 
21
23
  context 'tag sets provided' do
22
- let(:tag_sets) { [tag_set] }
24
+
25
+ let(:tag_sets) do
26
+ [ tag_set ]
27
+ end
23
28
 
24
29
  it 'raises an error' do
25
- expect{read_pref.tag_sets}.to raise_error
30
+ expect {
31
+ selector.tag_sets
32
+ }.to raise_error(Mongo::Error::InvalidServerPreference)
26
33
  end
27
34
  end
28
35
  end
@@ -30,7 +37,7 @@ describe Mongo::ServerSelector::Primary do
30
37
  describe '#to_mongos' do
31
38
 
32
39
  it 'returns nil' do
33
- expect(read_pref.to_mongos).to be_nil
40
+ expect(selector.to_mongos).to be_nil
34
41
  end
35
42
  end
36
43
 
@@ -40,7 +47,7 @@ describe Mongo::ServerSelector::Primary do
40
47
  let(:candidates) { [] }
41
48
 
42
49
  it 'returns an empty array' do
43
- expect(read_pref.send(:select, candidates)).to be_empty
50
+ expect(selector.send(:select, candidates)).to be_empty
44
51
  end
45
52
  end
46
53
 
@@ -48,7 +55,7 @@ describe Mongo::ServerSelector::Primary do
48
55
  let(:candidates) { [secondary] }
49
56
 
50
57
  it 'returns an empty array' do
51
- expect(read_pref.send(:select, candidates)).to be_empty
58
+ expect(selector.send(:select, candidates)).to be_empty
52
59
  end
53
60
  end
54
61
 
@@ -56,7 +63,7 @@ describe Mongo::ServerSelector::Primary do
56
63
  let(:candidates) { [primary] }
57
64
 
58
65
  it 'returns an array with the primary' do
59
- expect(read_pref.send(:select, candidates)).to eq([primary])
66
+ expect(selector.send(:select, candidates)).to eq([primary])
60
67
  end
61
68
  end
62
69
 
@@ -64,7 +71,7 @@ describe Mongo::ServerSelector::Primary do
64
71
  let(:candidates) { [secondary, primary] }
65
72
 
66
73
  it 'returns an array with the primary' do
67
- expect(read_pref.send(:select, candidates)).to eq([primary])
74
+ expect(selector.send(:select, candidates)).to eq([primary])
68
75
  end
69
76
  end
70
77
 
@@ -78,7 +85,7 @@ describe Mongo::ServerSelector::Primary do
78
85
  let(:candidates) { [far_primary] }
79
86
 
80
87
  it 'returns array with the primary' do
81
- expect(read_pref.send(:select, candidates)).to eq([far_primary])
88
+ expect(selector.send(:select, candidates)).to eq([far_primary])
82
89
  end
83
90
  end
84
91
 
@@ -86,7 +93,7 @@ describe Mongo::ServerSelector::Primary do
86
93
  let(:candidates) { [far_secondary] }
87
94
 
88
95
  it 'returns empty array' do
89
- expect(read_pref.send(:select, candidates)).to be_empty
96
+ expect(selector.send(:select, candidates)).to be_empty
90
97
  end
91
98
  end
92
99
  end
@@ -97,7 +104,7 @@ describe Mongo::ServerSelector::Primary do
97
104
  let(:candidates) { [far_primary, far_secondary] }
98
105
 
99
106
  it 'returns an array with the primary' do
100
- expect(read_pref.send(:select, candidates)).to eq([far_primary])
107
+ expect(selector.send(:select, candidates)).to eq([far_primary])
101
108
  end
102
109
  end
103
110
 
@@ -105,7 +112,7 @@ describe Mongo::ServerSelector::Primary do
105
112
  let(:candidates) { [far_primary, far_secondary] }
106
113
 
107
114
  it 'returns an array with the primary' do
108
- expect(read_pref.send(:select, candidates)).to eq([far_primary])
115
+ expect(selector.send(:select, candidates)).to eq([far_primary])
109
116
  end
110
117
  end
111
118
  end