mongoid 3.1.7 → 4.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (521) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +317 -11
  3. data/README.md +4 -5
  4. data/lib/config/locales/en.yml +9 -12
  5. data/lib/mongoid.rb +6 -75
  6. data/lib/mongoid/atomic.rb +0 -11
  7. data/lib/mongoid/atomic/paths/embedded.rb +0 -30
  8. data/lib/mongoid/atomic/paths/root.rb +0 -13
  9. data/lib/mongoid/attributes.rb +30 -108
  10. data/lib/mongoid/attributes/dynamic.rb +154 -0
  11. data/lib/mongoid/attributes/nested.rb +82 -0
  12. data/lib/mongoid/attributes/processing.rb +13 -66
  13. data/lib/mongoid/{dirty.rb → changeable.rb} +5 -2
  14. data/lib/mongoid/composable.rb +104 -0
  15. data/lib/mongoid/config.rb +3 -9
  16. data/lib/mongoid/config/options.rb +1 -1
  17. data/lib/mongoid/contextual/aggregable/mongo.rb +5 -9
  18. data/lib/mongoid/contextual/atomic.rb +53 -53
  19. data/lib/mongoid/contextual/command.rb +26 -0
  20. data/lib/mongoid/contextual/map_reduce.rb +1 -1
  21. data/lib/mongoid/contextual/memory.rb +6 -5
  22. data/lib/mongoid/contextual/mongo.rb +59 -28
  23. data/lib/mongoid/contextual/text_search.rb +180 -0
  24. data/lib/mongoid/copyable.rb +2 -3
  25. data/lib/mongoid/criteria.rb +13 -33
  26. data/lib/mongoid/criteria/{#findable.rb# → findable.rb} +0 -2
  27. data/lib/mongoid/{criterion/inspection.rb → criteria/inspectable.rb} +2 -2
  28. data/lib/mongoid/{criterion → criteria}/marshalable.rb +3 -1
  29. data/lib/mongoid/{criterion → criteria}/modifiable.rb +1 -1
  30. data/lib/mongoid/{criterion/scoping.rb → criteria/scopable.rb} +2 -2
  31. data/lib/mongoid/document.rb +28 -12
  32. data/lib/mongoid/errors.rb +1 -1
  33. data/lib/mongoid/errors/document_not_found.rb +2 -1
  34. data/lib/mongoid/errors/invalid_value.rb +16 -0
  35. data/lib/mongoid/errors/mongoid_error.rb +1 -1
  36. data/lib/mongoid/extensions.rb +2 -7
  37. data/lib/mongoid/extensions/array.rb +2 -2
  38. data/lib/mongoid/extensions/boolean.rb +14 -17
  39. data/lib/mongoid/extensions/float.rb +1 -0
  40. data/lib/mongoid/extensions/hash.rb +1 -1
  41. data/lib/mongoid/extensions/object.rb +4 -4
  42. data/lib/mongoid/extensions/object_id.rb +5 -5
  43. data/lib/mongoid/extensions/range.rb +8 -2
  44. data/lib/mongoid/extensions/string.rb +5 -17
  45. data/lib/mongoid/extensions/time.rb +2 -2
  46. data/lib/mongoid/factory.rb +3 -3
  47. data/lib/mongoid/fields.rb +9 -8
  48. data/lib/mongoid/fields/foreign_key.rb +3 -3
  49. data/lib/mongoid/fields/standard.rb +4 -16
  50. data/lib/mongoid/fields/validators/macro.rb +11 -3
  51. data/lib/mongoid/{finders.rb → findable.rb} +6 -2
  52. data/lib/mongoid/{indexes.rb → indexable.rb} +50 -55
  53. data/lib/mongoid/indexable/specification.rb +104 -0
  54. data/lib/mongoid/{indexes → indexable}/validators/options.rb +2 -1
  55. data/lib/mongoid/{inspection.rb → inspectable.rb} +15 -11
  56. data/lib/mongoid/{callbacks.rb → interceptable.rb} +3 -52
  57. data/lib/mongoid/log_subscriber.rb +22 -0
  58. data/lib/mongoid/matchable.rb +152 -0
  59. data/lib/mongoid/{matchers → matchable}/all.rb +1 -1
  60. data/lib/mongoid/{matchers → matchable}/and.rb +2 -2
  61. data/lib/mongoid/{matchers → matchable}/default.rb +1 -1
  62. data/lib/mongoid/{matchers → matchable}/exists.rb +1 -1
  63. data/lib/mongoid/{matchers → matchable}/gt.rb +1 -1
  64. data/lib/mongoid/{matchers → matchable}/gte.rb +1 -1
  65. data/lib/mongoid/{matchers → matchable}/in.rb +2 -2
  66. data/lib/mongoid/{matchers → matchable}/lt.rb +1 -1
  67. data/lib/mongoid/{matchers → matchable}/lte.rb +1 -1
  68. data/lib/mongoid/{matchers → matchable}/ne.rb +1 -1
  69. data/lib/mongoid/{matchers → matchable}/nin.rb +3 -2
  70. data/lib/mongoid/{matchers → matchable}/or.rb +2 -2
  71. data/lib/mongoid/{matchers → matchable}/size.rb +1 -1
  72. data/lib/mongoid/persistable.rb +212 -0
  73. data/lib/mongoid/persistable/creatable.rb +188 -0
  74. data/lib/mongoid/persistable/deletable.rb +148 -0
  75. data/lib/mongoid/persistable/destroyable.rb +55 -0
  76. data/lib/mongoid/persistable/incrementable.rb +36 -0
  77. data/lib/mongoid/persistable/logical.rb +38 -0
  78. data/lib/mongoid/persistable/poppable.rb +39 -0
  79. data/lib/mongoid/persistable/pullable.rb +55 -0
  80. data/lib/mongoid/persistable/pushable.rb +62 -0
  81. data/lib/mongoid/persistable/renamable.rb +35 -0
  82. data/lib/mongoid/persistable/savable.rb +52 -0
  83. data/lib/mongoid/persistable/settable.rb +33 -0
  84. data/lib/mongoid/persistable/unsettable.rb +36 -0
  85. data/lib/mongoid/persistable/updatable.rb +151 -0
  86. data/lib/mongoid/persistable/upsertable.rb +55 -0
  87. data/lib/mongoid/positional.rb +71 -0
  88. data/lib/mongoid/railtie.rb +32 -45
  89. data/lib/mongoid/railties/database.rake +12 -6
  90. data/lib/mongoid/relations.rb +3 -3
  91. data/lib/mongoid/relations/accessors.rb +13 -46
  92. data/lib/mongoid/relations/auto_save.rb +15 -36
  93. data/lib/mongoid/relations/binding.rb +0 -23
  94. data/lib/mongoid/relations/bindings/embedded/many.rb +1 -3
  95. data/lib/mongoid/relations/bindings/referenced/in.rb +3 -8
  96. data/lib/mongoid/relations/bindings/referenced/many_to_many.rb +3 -1
  97. data/lib/mongoid/relations/builder.rb +1 -1
  98. data/lib/mongoid/relations/builders.rb +2 -2
  99. data/lib/mongoid/relations/builders/nested_attributes/many.rb +10 -13
  100. data/lib/mongoid/relations/builders/nested_attributes/one.rb +4 -5
  101. data/lib/mongoid/relations/builders/referenced/in.rb +1 -1
  102. data/lib/mongoid/relations/builders/referenced/many.rb +1 -2
  103. data/lib/mongoid/relations/builders/referenced/many_to_many.rb +1 -2
  104. data/lib/mongoid/relations/builders/referenced/one.rb +1 -1
  105. data/lib/mongoid/relations/cascading.rb +3 -5
  106. data/lib/mongoid/relations/constraint.rb +1 -1
  107. data/lib/mongoid/relations/conversions.rb +1 -1
  108. data/lib/mongoid/relations/counter_cache.rb +39 -15
  109. data/lib/mongoid/relations/eager.rb +47 -0
  110. data/lib/mongoid/relations/eager/base.rb +57 -0
  111. data/lib/mongoid/relations/eager/belongs_to.rb +30 -0
  112. data/lib/mongoid/relations/eager/has_and_belongs_to_many.rb +40 -0
  113. data/lib/mongoid/relations/eager/has_many.rb +37 -0
  114. data/lib/mongoid/relations/eager/has_one.rb +29 -0
  115. data/lib/mongoid/relations/embedded/batchable.rb +3 -4
  116. data/lib/mongoid/relations/embedded/many.rb +7 -27
  117. data/lib/mongoid/relations/macros.rb +2 -4
  118. data/lib/mongoid/relations/many.rb +30 -31
  119. data/lib/mongoid/relations/metadata.rb +6 -75
  120. data/lib/mongoid/relations/nested_builder.rb +2 -2
  121. data/lib/mongoid/relations/options.rb +1 -0
  122. data/lib/mongoid/relations/polymorphic.rb +0 -1
  123. data/lib/mongoid/relations/proxy.rb +10 -32
  124. data/lib/mongoid/relations/referenced/in.rb +2 -18
  125. data/lib/mongoid/relations/referenced/many.rb +9 -22
  126. data/lib/mongoid/relations/referenced/many_to_many.rb +10 -33
  127. data/lib/mongoid/relations/referenced/one.rb +2 -21
  128. data/lib/mongoid/relations/synchronization.rb +3 -3
  129. data/lib/mongoid/relations/touchable.rb +33 -0
  130. data/lib/mongoid/{reloading.rb → reloadable.rb} +6 -4
  131. data/lib/mongoid/{scoping.rb → scopable.rb} +26 -3
  132. data/lib/mongoid/selectable.rb +59 -0
  133. data/lib/mongoid/{serialization.rb → serializable.rb} +10 -1
  134. data/lib/mongoid/sessions.rb +37 -345
  135. data/lib/mongoid/sessions/factory.rb +2 -0
  136. data/lib/mongoid/sessions/options.rb +176 -0
  137. data/lib/mongoid/sessions/storage_options.rb +140 -0
  138. data/lib/mongoid/sessions/thread_options.rb +19 -0
  139. data/lib/mongoid/sessions/validators/storage.rb +15 -1
  140. data/lib/mongoid/{sharding.rb → shardable.rb} +5 -1
  141. data/lib/mongoid/support/query_counter.rb +23 -0
  142. data/lib/mongoid/threaded.rb +0 -110
  143. data/lib/mongoid/threaded/lifecycle.rb +0 -28
  144. data/lib/mongoid/timestamps/updated/short.rb +2 -2
  145. data/lib/mongoid/{hierarchy.rb → traversable.rb} +9 -5
  146. data/lib/mongoid/{validations.rb → validatable.rb} +23 -9
  147. data/lib/mongoid/{validations → validatable}/associated.rb +3 -1
  148. data/lib/mongoid/{validations → validatable}/format.rb +1 -1
  149. data/lib/mongoid/{validations → validatable}/length.rb +1 -1
  150. data/lib/mongoid/{validations → validatable}/localizable.rb +1 -1
  151. data/lib/mongoid/{validations → validatable}/macros.rb +4 -3
  152. data/lib/mongoid/{validations → validatable}/presence.rb +1 -1
  153. data/lib/mongoid/{validations → validatable}/queryable.rb +1 -2
  154. data/lib/mongoid/{validations → validatable}/uniqueness.rb +3 -3
  155. data/lib/mongoid/version.rb +1 -1
  156. data/lib/rails/generators/mongoid/config/templates/mongoid.yml +9 -13
  157. data/lib/rails/generators/mongoid/model/model_generator.rb +0 -1
  158. data/lib/rails/generators/mongoid/model/templates/model.rb.tt +0 -3
  159. data/lib/rails/generators/mongoid_generator.rb +3 -40
  160. data/lib/rails/mongoid.rb +59 -57
  161. data/lib/support/ruby_version.rb +1 -1
  162. data/spec/app/models/account.rb +2 -6
  163. data/spec/app/models/acolyte.rb +1 -0
  164. data/spec/app/models/actor.rb +0 -1
  165. data/spec/app/models/address.rb +6 -1
  166. data/spec/app/models/animal.rb +1 -1
  167. data/spec/app/models/appointment.rb +2 -2
  168. data/spec/app/models/article.rb +1 -4
  169. data/spec/app/models/audio.rb +5 -0
  170. data/spec/app/models/author.rb +0 -2
  171. data/spec/app/models/band.rb +3 -2
  172. data/spec/app/models/bar.rb +1 -0
  173. data/spec/app/models/book.rb +1 -0
  174. data/spec/app/models/building.rb +0 -2
  175. data/spec/app/models/building_address.rb +0 -2
  176. data/spec/app/models/bus.rb +1 -1
  177. data/spec/app/models/canvas.rb +1 -1
  178. data/spec/app/models/contractor.rb +0 -2
  179. data/spec/app/models/country_code.rb +1 -1
  180. data/spec/app/models/definition.rb +2 -2
  181. data/spec/app/models/dragon.rb +4 -0
  182. data/spec/app/models/drug.rb +1 -3
  183. data/spec/app/models/dungeon.rb +4 -0
  184. data/spec/app/models/filesystem.rb +1 -0
  185. data/spec/app/models/fish.rb +0 -1
  186. data/spec/app/models/fruits.rb +6 -0
  187. data/spec/app/models/game.rb +0 -2
  188. data/spec/app/models/house.rb +0 -2
  189. data/spec/app/models/item.rb +1 -5
  190. data/spec/app/models/jar.rb +1 -1
  191. data/spec/app/models/label.rb +4 -4
  192. data/spec/app/models/login.rb +1 -1
  193. data/spec/app/models/movie.rb +1 -0
  194. data/spec/app/models/name.rb +3 -3
  195. data/spec/app/models/note.rb +1 -1
  196. data/spec/app/models/oscar.rb +1 -1
  197. data/spec/app/models/parent_doc.rb +1 -1
  198. data/spec/app/models/person.rb +13 -8
  199. data/spec/app/models/phone.rb +1 -3
  200. data/spec/app/models/player.rb +1 -1
  201. data/spec/app/models/post.rb +2 -1
  202. data/spec/app/models/quiz.rb +0 -3
  203. data/spec/app/models/record.rb +5 -5
  204. data/spec/app/models/registry.rb +1 -1
  205. data/spec/app/models/server.rb +1 -1
  206. data/spec/app/models/service.rb +3 -3
  207. data/spec/app/models/sound.rb +5 -0
  208. data/spec/app/models/template.rb +1 -1
  209. data/spec/app/models/title.rb +0 -1
  210. data/spec/app/models/track.rb +5 -5
  211. data/spec/app/models/tree.rb +1 -1
  212. data/spec/app/models/video.rb +0 -4
  213. data/spec/app/models/wiki_page.rb +1 -4
  214. data/spec/app/models/word.rb +3 -0
  215. data/spec/app/models/word_origin.rb +1 -1
  216. data/spec/config/mongoid.yml +7 -8
  217. data/spec/helpers.rb +18 -0
  218. data/spec/mongoid/atomic/modifiers_spec.rb +22 -22
  219. data/spec/mongoid/atomic/paths/embedded/many_spec.rb +8 -49
  220. data/spec/mongoid/atomic/paths/embedded/one_spec.rb +7 -49
  221. data/spec/mongoid/atomic/paths/root_spec.rb +3 -61
  222. data/spec/mongoid/atomic/paths_spec.rb +19 -19
  223. data/spec/mongoid/atomic_spec.rb +19 -19
  224. data/spec/mongoid/{nested_attributes_spec.rb → attributes/nested_spec.rb} +335 -448
  225. data/spec/mongoid/attributes/readonly_spec.rb +16 -16
  226. data/spec/mongoid/attributes_spec.rb +188 -434
  227. data/spec/mongoid/{dirty_spec.rb → changeable_spec.rb} +117 -148
  228. data/spec/mongoid/{components_spec.rb → composable_spec.rb} +3 -3
  229. data/spec/mongoid/config/environment_spec.rb +3 -3
  230. data/spec/mongoid/config/options_spec.rb +6 -6
  231. data/spec/mongoid/config_spec.rb +24 -48
  232. data/spec/mongoid/contextual/aggregable/memory_spec.rb +12 -12
  233. data/spec/mongoid/contextual/aggregable/mongo_spec.rb +46 -38
  234. data/spec/mongoid/contextual/atomic_spec.rb +60 -56
  235. data/spec/mongoid/contextual/find_and_modify_spec.rb +14 -14
  236. data/spec/mongoid/contextual/geo_near_spec.rb +22 -22
  237. data/spec/mongoid/contextual/map_reduce_spec.rb +27 -27
  238. data/spec/mongoid/contextual/memory_spec.rb +94 -94
  239. data/spec/mongoid/contextual/mongo_spec.rb +225 -139
  240. data/spec/mongoid/contextual/text_search_spec.rb +207 -0
  241. data/spec/mongoid/copyable_spec.rb +56 -68
  242. data/spec/mongoid/criteria/findable_spec.rb +991 -0
  243. data/spec/mongoid/{criterion/inspection_spec.rb → criteria/inspectable_spec.rb} +5 -5
  244. data/spec/mongoid/{criterion → criteria}/marshalable_spec.rb +2 -2
  245. data/spec/mongoid/criteria/modifiable_spec.rb +1063 -0
  246. data/spec/mongoid/{criterion/scoping_spec.rb → criteria/scopable_spec.rb} +31 -31
  247. data/spec/mongoid/criteria_spec.rb +530 -2207
  248. data/spec/mongoid/document_spec.rb +166 -120
  249. data/spec/mongoid/equality_spec.rb +22 -22
  250. data/spec/mongoid/errors/ambiguous_relationship_spec.rb +3 -3
  251. data/spec/mongoid/errors/callback_spec.rb +3 -3
  252. data/spec/mongoid/errors/delete_restriction_spec.rb +3 -3
  253. data/spec/mongoid/errors/document_not_found_spec.rb +11 -11
  254. data/spec/mongoid/errors/eager_load_spec.rb +3 -3
  255. data/spec/mongoid/errors/invalid_collection_spec.rb +3 -3
  256. data/spec/mongoid/errors/invalid_config_option_spec.rb +3 -3
  257. data/spec/mongoid/errors/invalid_field_option_spec.rb +3 -3
  258. data/spec/mongoid/errors/invalid_field_spec.rb +3 -3
  259. data/spec/mongoid/errors/invalid_find_spec.rb +3 -3
  260. data/spec/mongoid/errors/invalid_includes_spec.rb +3 -3
  261. data/spec/mongoid/errors/invalid_index_spec.rb +3 -3
  262. data/spec/mongoid/errors/invalid_options_spec.rb +3 -3
  263. data/spec/mongoid/errors/invalid_path_spec.rb +3 -3
  264. data/spec/mongoid/errors/invalid_scope_spec.rb +3 -3
  265. data/spec/mongoid/errors/invalid_set_polymorphic_relation_spec.rb +3 -3
  266. data/spec/mongoid/errors/invalid_storage_options_spec.rb +3 -3
  267. data/spec/mongoid/errors/invalid_time_spec.rb +3 -3
  268. data/spec/mongoid/errors/inverse_not_found_spec.rb +3 -3
  269. data/spec/mongoid/errors/mixed_relations_spec.rb +3 -3
  270. data/spec/mongoid/errors/mixed_session_configuration_spec.rb +3 -3
  271. data/spec/mongoid/errors/mongoid_error_spec.rb +7 -7
  272. data/spec/mongoid/errors/nested_attributes_metadata_not_found_spec.rb +3 -3
  273. data/spec/mongoid/errors/no_environment_spec.rb +3 -3
  274. data/spec/mongoid/errors/no_map_reduce_output_spec.rb +3 -3
  275. data/spec/mongoid/errors/no_metadata_spec.rb +3 -3
  276. data/spec/mongoid/errors/no_parent_spec.rb +3 -3
  277. data/spec/mongoid/errors/no_session_config_spec.rb +3 -3
  278. data/spec/mongoid/errors/no_session_database_spec.rb +3 -3
  279. data/spec/mongoid/errors/no_session_hosts_spec.rb +3 -3
  280. data/spec/mongoid/errors/no_sessions_config_spec.rb +3 -3
  281. data/spec/mongoid/errors/readonly_attribute_spec.rb +3 -3
  282. data/spec/mongoid/errors/scope_overwrite_spec.rb +3 -3
  283. data/spec/mongoid/errors/too_many_nested_attribute_records_spec.rb +3 -3
  284. data/spec/mongoid/errors/unknown_attribute_spec.rb +5 -5
  285. data/spec/mongoid/errors/unsaved_document_spec.rb +3 -3
  286. data/spec/mongoid/errors/unsupported_javascript_spec.rb +3 -3
  287. data/spec/mongoid/errors/validations_spec.rb +7 -7
  288. data/spec/mongoid/extensions/array_spec.rb +61 -61
  289. data/spec/mongoid/extensions/big_decimal_spec.rb +11 -11
  290. data/spec/mongoid/extensions/binary_spec.rb +12 -12
  291. data/spec/mongoid/extensions/boolean_spec.rb +18 -18
  292. data/spec/mongoid/extensions/date_spec.rb +13 -13
  293. data/spec/mongoid/extensions/date_time_spec.rb +9 -9
  294. data/spec/mongoid/extensions/false_class_spec.rb +5 -5
  295. data/spec/mongoid/extensions/float_spec.rb +29 -15
  296. data/spec/mongoid/extensions/hash_spec.rb +29 -29
  297. data/spec/mongoid/extensions/integer_spec.rb +15 -15
  298. data/spec/mongoid/extensions/module_spec.rb +2 -2
  299. data/spec/mongoid/extensions/nil_class_spec.rb +1 -1
  300. data/spec/mongoid/extensions/object_id_spec.rb +134 -134
  301. data/spec/mongoid/extensions/object_spec.rb +26 -26
  302. data/spec/mongoid/extensions/range_spec.rb +61 -12
  303. data/spec/mongoid/extensions/regexp_spec.rb +4 -4
  304. data/spec/mongoid/extensions/set_spec.rb +4 -4
  305. data/spec/mongoid/extensions/string_spec.rb +35 -46
  306. data/spec/mongoid/extensions/symbol_spec.rb +9 -9
  307. data/spec/mongoid/extensions/time_spec.rb +49 -49
  308. data/spec/mongoid/extensions/time_with_zone_spec.rb +34 -34
  309. data/spec/mongoid/extensions/true_class_spec.rb +5 -5
  310. data/spec/mongoid/extensions_spec.rb +15 -0
  311. data/spec/mongoid/factory_spec.rb +15 -15
  312. data/spec/mongoid/fields/foreign_key_spec.rb +73 -66
  313. data/spec/mongoid/fields/internal/foreign_keys/array_spec.rb +15 -15
  314. data/spec/mongoid/fields/internal/foreign_keys/object_spec.rb +22 -22
  315. data/spec/mongoid/fields/localized_spec.rb +23 -23
  316. data/spec/mongoid/fields/standard_spec.rb +12 -12
  317. data/spec/mongoid/fields_spec.rb +168 -209
  318. data/spec/mongoid/{finders_spec.rb → findable_spec.rb} +62 -27
  319. data/spec/mongoid/indexable/specification_spec.rb +102 -0
  320. data/spec/mongoid/{indexes_spec.rb → indexable_spec.rb} +171 -51
  321. data/spec/mongoid/{inspection_spec.rb → inspectable_spec.rb} +6 -14
  322. data/spec/mongoid/{callbacks_spec.rb → interceptable_spec.rb} +105 -105
  323. data/spec/mongoid/log_subscriber_spec.rb +74 -0
  324. data/spec/mongoid/loggable_spec.rb +1 -1
  325. data/spec/mongoid/{matchers → matchable}/all_spec.rb +4 -4
  326. data/spec/mongoid/{matchers → matchable}/and_spec.rb +11 -11
  327. data/spec/mongoid/{matchers → matchable}/default_spec.rb +15 -15
  328. data/spec/mongoid/{matchers → matchable}/exists_spec.rb +5 -5
  329. data/spec/mongoid/{matchers → matchable}/gt_spec.rb +9 -8
  330. data/spec/mongoid/{matchers → matchable}/gte_spec.rb +7 -7
  331. data/spec/mongoid/matchable/in_spec.rb +49 -0
  332. data/spec/mongoid/{matchers → matchable}/lt_spec.rb +7 -7
  333. data/spec/mongoid/{matchers → matchable}/lte_spec.rb +7 -7
  334. data/spec/mongoid/{matchers → matchable}/ne_spec.rb +3 -3
  335. data/spec/mongoid/matchable/nin_spec.rb +48 -0
  336. data/spec/mongoid/{matchers → matchable}/or_spec.rb +6 -6
  337. data/spec/mongoid/{matchers → matchable}/size_spec.rb +3 -3
  338. data/spec/mongoid/{matchers_spec.rb → matchable_spec.rb} +41 -41
  339. data/spec/mongoid/persistable/creatable_spec.rb +512 -0
  340. data/spec/mongoid/persistable/deletable_spec.rb +205 -0
  341. data/spec/mongoid/persistable/destroyable_spec.rb +148 -0
  342. data/spec/mongoid/persistable/incrementable_spec.rb +173 -0
  343. data/spec/mongoid/persistable/logical_spec.rb +143 -0
  344. data/spec/mongoid/persistable/poppable_spec.rb +115 -0
  345. data/spec/mongoid/persistable/pullable_spec.rb +228 -0
  346. data/spec/mongoid/persistable/pushable_spec.rb +258 -0
  347. data/spec/mongoid/persistable/renamable_spec.rb +135 -0
  348. data/spec/mongoid/persistable/savable_spec.rb +432 -0
  349. data/spec/mongoid/persistable/settable_spec.rb +139 -0
  350. data/spec/mongoid/persistable/unsettable_spec.rb +155 -0
  351. data/spec/mongoid/persistable/updatable_spec.rb +558 -0
  352. data/spec/mongoid/persistable/upsertable_spec.rb +106 -0
  353. data/spec/mongoid/persistable_spec.rb +206 -0
  354. data/spec/mongoid/{atomic/positionable_spec.rb → positional_spec.rb} +19 -14
  355. data/spec/mongoid/railties/document_spec.rb +2 -2
  356. data/spec/mongoid/relations/accessors_spec.rb +53 -145
  357. data/spec/mongoid/relations/auto_save_spec.rb +36 -16
  358. data/spec/mongoid/relations/bindings/embedded/in_spec.rb +6 -6
  359. data/spec/mongoid/relations/bindings/embedded/many_spec.rb +2 -2
  360. data/spec/mongoid/relations/bindings/embedded/one_spec.rb +3 -3
  361. data/spec/mongoid/relations/bindings/referenced/in_spec.rb +12 -12
  362. data/spec/mongoid/relations/bindings/referenced/many_spec.rb +6 -6
  363. data/spec/mongoid/relations/bindings/referenced/many_to_many_spec.rb +9 -9
  364. data/spec/mongoid/relations/bindings/referenced/one_spec.rb +6 -6
  365. data/spec/mongoid/relations/builders/embedded/in_spec.rb +4 -4
  366. data/spec/mongoid/relations/builders/embedded/many_spec.rb +18 -18
  367. data/spec/mongoid/relations/builders/embedded/one_spec.rb +11 -11
  368. data/spec/mongoid/relations/builders/nested_attributes/many_spec.rb +12 -13
  369. data/spec/mongoid/relations/builders/nested_attributes/one_spec.rb +14 -14
  370. data/spec/mongoid/relations/builders/referenced/in_spec.rb +22 -33
  371. data/spec/mongoid/relations/builders/referenced/many_spec.rb +15 -15
  372. data/spec/mongoid/relations/builders/referenced/many_to_many_spec.rb +18 -18
  373. data/spec/mongoid/relations/builders/referenced/one_spec.rb +11 -24
  374. data/spec/mongoid/relations/builders_spec.rb +21 -21
  375. data/spec/mongoid/relations/cascading/delete_spec.rb +7 -7
  376. data/spec/mongoid/relations/cascading/destroy_spec.rb +2 -2
  377. data/spec/mongoid/relations/cascading/nullify_spec.rb +2 -2
  378. data/spec/mongoid/relations/cascading/restrict_spec.rb +3 -3
  379. data/spec/mongoid/relations/cascading_spec.rb +16 -16
  380. data/spec/mongoid/relations/constraint_spec.rb +8 -7
  381. data/spec/mongoid/relations/conversions_spec.rb +16 -14
  382. data/spec/mongoid/relations/counter_cache_spec.rb +85 -0
  383. data/spec/mongoid/relations/cyclic_spec.rb +18 -18
  384. data/spec/mongoid/relations/eager/belongs_to_spec.rb +154 -0
  385. data/spec/mongoid/relations/eager/has_and_belongs_to_many_spec.rb +143 -0
  386. data/spec/mongoid/relations/eager/has_many_spec.rb +207 -0
  387. data/spec/mongoid/relations/eager/has_one_spec.rb +163 -0
  388. data/spec/mongoid/relations/eager_spec.rb +228 -0
  389. data/spec/mongoid/relations/embedded/dirty_spec.rb +8 -8
  390. data/spec/mongoid/relations/embedded/in_spec.rb +55 -56
  391. data/spec/mongoid/relations/embedded/many_spec.rb +357 -367
  392. data/spec/mongoid/relations/embedded/one_spec.rb +98 -139
  393. data/spec/mongoid/relations/macros_spec.rb +108 -102
  394. data/spec/mongoid/relations/metadata_spec.rb +147 -241
  395. data/spec/mongoid/relations/options_spec.rb +1 -1
  396. data/spec/mongoid/relations/polymorphic_spec.rb +13 -17
  397. data/spec/mongoid/relations/proxy_spec.rb +2 -2
  398. data/spec/mongoid/relations/referenced/in_spec.rb +128 -303
  399. data/spec/mongoid/relations/referenced/many_spec.rb +379 -522
  400. data/spec/mongoid/relations/referenced/many_to_many_spec.rb +345 -417
  401. data/spec/mongoid/relations/referenced/one_spec.rb +148 -263
  402. data/spec/mongoid/relations/reflections_spec.rb +6 -6
  403. data/spec/mongoid/relations/synchronization_spec.rb +46 -50
  404. data/spec/mongoid/relations/targets/enumerable_spec.rb +116 -116
  405. data/spec/mongoid/relations/touchable_spec.rb +296 -0
  406. data/spec/mongoid/relations_spec.rb +16 -15
  407. data/spec/mongoid/{reloading_spec.rb → reloadable_spec.rb} +20 -60
  408. data/spec/mongoid/{scoping_spec.rb → scopable_spec.rb} +74 -126
  409. data/spec/mongoid/selectable_spec.rb +134 -0
  410. data/spec/mongoid/{serialization_spec.rb → serializable_spec.rb} +111 -82
  411. data/spec/mongoid/sessions/factory_spec.rb +49 -28
  412. data/spec/mongoid/sessions/mongo_uri_spec.rb +7 -7
  413. data/spec/mongoid/sessions/options_spec.rb +92 -0
  414. data/spec/mongoid/sessions_spec.rb +288 -177
  415. data/spec/mongoid/{sharding_spec.rb → shardable_spec.rb} +8 -8
  416. data/spec/mongoid/state_spec.rb +10 -10
  417. data/spec/mongoid/threaded_spec.rb +17 -70
  418. data/spec/mongoid/timestamps/created/short_spec.rb +6 -6
  419. data/spec/mongoid/timestamps/created_spec.rb +5 -5
  420. data/spec/mongoid/timestamps/updated/short_spec.rb +10 -10
  421. data/spec/mongoid/timestamps/updated_spec.rb +8 -12
  422. data/spec/mongoid/timestamps_spec.rb +7 -11
  423. data/spec/mongoid/{hierarchy_spec.rb → traversable_spec.rb} +19 -19
  424. data/spec/mongoid/{validations → validatable}/associated_spec.rb +18 -18
  425. data/spec/mongoid/{validations → validatable}/format_spec.rb +6 -6
  426. data/spec/mongoid/{validations → validatable}/length_spec.rb +7 -7
  427. data/spec/mongoid/{validations → validatable}/numericality_spec.rb +1 -1
  428. data/spec/mongoid/{validations → validatable}/presence_spec.rb +31 -38
  429. data/spec/mongoid/{validations → validatable}/uniqueness_spec.rb +126 -183
  430. data/spec/mongoid/{validations_spec.rb → validatable_spec.rb} +28 -28
  431. data/spec/mongoid_spec.rb +8 -8
  432. data/spec/rails/mongoid_spec.rb +72 -87
  433. data/spec/spec_helper.rb +19 -17
  434. metadata +261 -283
  435. data/lib/mongoid/atomic/positionable.rb +0 -73
  436. data/lib/mongoid/components.rb +0 -92
  437. data/lib/mongoid/config/inflections.rb +0 -6
  438. data/lib/mongoid/contextual/eager.rb +0 -158
  439. data/lib/mongoid/criterion/findable.rb +0 -179
  440. data/lib/mongoid/errors/versioning_not_on_root.rb +0 -23
  441. data/lib/mongoid/identity_map.rb +0 -163
  442. data/lib/mongoid/json.rb +0 -16
  443. data/lib/mongoid/matchers.rb +0 -32
  444. data/lib/mongoid/matchers/strategies.rb +0 -97
  445. data/lib/mongoid/multi_parameter_attributes.rb +0 -105
  446. data/lib/mongoid/nested_attributes.rb +0 -78
  447. data/lib/mongoid/observer.rb +0 -192
  448. data/lib/mongoid/paranoia.rb +0 -136
  449. data/lib/mongoid/persistence.rb +0 -357
  450. data/lib/mongoid/persistence/atomic.rb +0 -231
  451. data/lib/mongoid/persistence/atomic/add_to_set.rb +0 -47
  452. data/lib/mongoid/persistence/atomic/bit.rb +0 -35
  453. data/lib/mongoid/persistence/atomic/inc.rb +0 -45
  454. data/lib/mongoid/persistence/atomic/operation.rb +0 -154
  455. data/lib/mongoid/persistence/atomic/pop.rb +0 -32
  456. data/lib/mongoid/persistence/atomic/pull.rb +0 -32
  457. data/lib/mongoid/persistence/atomic/pull_all.rb +0 -32
  458. data/lib/mongoid/persistence/atomic/push.rb +0 -25
  459. data/lib/mongoid/persistence/atomic/push_all.rb +0 -25
  460. data/lib/mongoid/persistence/atomic/rename.rb +0 -30
  461. data/lib/mongoid/persistence/atomic/sets.rb +0 -28
  462. data/lib/mongoid/persistence/atomic/unset.rb +0 -27
  463. data/lib/mongoid/persistence/deletion.rb +0 -31
  464. data/lib/mongoid/persistence/insertion.rb +0 -38
  465. data/lib/mongoid/persistence/modification.rb +0 -35
  466. data/lib/mongoid/persistence/operations.rb +0 -214
  467. data/lib/mongoid/persistence/operations/embedded/insert.rb +0 -46
  468. data/lib/mongoid/persistence/operations/embedded/remove.rb +0 -43
  469. data/lib/mongoid/persistence/operations/insert.rb +0 -34
  470. data/lib/mongoid/persistence/operations/remove.rb +0 -33
  471. data/lib/mongoid/persistence/operations/update.rb +0 -59
  472. data/lib/mongoid/persistence/operations/upsert.rb +0 -28
  473. data/lib/mongoid/persistence/upsertion.rb +0 -31
  474. data/lib/mongoid/unit_of_work.rb +0 -61
  475. data/lib/mongoid/versioning.rb +0 -217
  476. data/lib/rack/mongoid.rb +0 -2
  477. data/lib/rack/mongoid/middleware/identity_map.rb +0 -39
  478. data/lib/rails/generators/mongoid/observer/observer_generator.rb +0 -17
  479. data/lib/rails/generators/mongoid/observer/templates/observer.rb.tt +0 -4
  480. data/spec/app/models/actor_observer.rb +0 -15
  481. data/spec/app/models/callback_recorder.rb +0 -25
  482. data/spec/app/models/draft.rb +0 -9
  483. data/spec/app/models/paranoid_phone.rb +0 -25
  484. data/spec/app/models/paranoid_post.rb +0 -36
  485. data/spec/app/models/phone_observer.rb +0 -6
  486. data/spec/mongoid/#atomic_spec.rb# +0 -365
  487. data/spec/mongoid/attributes/processing_spec.rb +0 -149
  488. data/spec/mongoid/criterion/destructive_spec.rb +0 -101
  489. data/spec/mongoid/criterion/modifiable_spec.rb +0 -409
  490. data/spec/mongoid/criterion/modification_spec.rb +0 -402
  491. data/spec/mongoid/errors/versioning_not_on_root_spec.rb +0 -29
  492. data/spec/mongoid/identity_map_spec.rb +0 -564
  493. data/spec/mongoid/json_spec.rb +0 -33
  494. data/spec/mongoid/matchers/in_spec.rb +0 -25
  495. data/spec/mongoid/matchers/nin_spec.rb +0 -25
  496. data/spec/mongoid/multi_parameter_attributes_spec.rb +0 -128
  497. data/spec/mongoid/observer_spec.rb +0 -290
  498. data/spec/mongoid/paranoia_spec.rb +0 -759
  499. data/spec/mongoid/persistence/atomic/add_to_set_spec.rb +0 -262
  500. data/spec/mongoid/persistence/atomic/bit_spec.rb +0 -88
  501. data/spec/mongoid/persistence/atomic/inc_spec.rb +0 -133
  502. data/spec/mongoid/persistence/atomic/pop_spec.rb +0 -111
  503. data/spec/mongoid/persistence/atomic/pull_all_spec.rb +0 -77
  504. data/spec/mongoid/persistence/atomic/pull_spec.rb +0 -80
  505. data/spec/mongoid/persistence/atomic/push_all_spec.rb +0 -77
  506. data/spec/mongoid/persistence/atomic/push_spec.rb +0 -77
  507. data/spec/mongoid/persistence/atomic/rename_spec.rb +0 -42
  508. data/spec/mongoid/persistence/atomic/sets_spec.rb +0 -154
  509. data/spec/mongoid/persistence/atomic/unset_spec.rb +0 -65
  510. data/spec/mongoid/persistence/atomic_spec.rb +0 -216
  511. data/spec/mongoid/persistence/operations/embedded/insert_spec.rb +0 -191
  512. data/spec/mongoid/persistence/operations/embedded/remove_spec.rb +0 -8
  513. data/spec/mongoid/persistence/operations/insert_spec.rb +0 -149
  514. data/spec/mongoid/persistence/operations/remove_spec.rb +0 -113
  515. data/spec/mongoid/persistence/operations/update_spec.rb +0 -141
  516. data/spec/mongoid/persistence/operations/upsert_spec.rb +0 -59
  517. data/spec/mongoid/persistence/operations_spec.rb +0 -313
  518. data/spec/mongoid/persistence_spec.rb +0 -2279
  519. data/spec/mongoid/unit_of_work_spec.rb +0 -196
  520. data/spec/mongoid/versioning_spec.rb +0 -540
  521. data/spec/rack/mongoid/middleware/identity_map_spec.rb +0 -72
@@ -7,11 +7,11 @@ describe "when initialize a model with an embedded model" do
7
7
  end
8
8
 
9
9
  it "has changes in the embedded model" do
10
- person.pet.changes.should_not be_empty
10
+ expect(person.pet.changes).to_not be_empty
11
11
  end
12
12
 
13
13
  it "does not have previous_changes in the embedded model" do
14
- person.pet.previous_changes.should be_empty
14
+ expect(person.pet.previous_changes).to be_empty
15
15
  end
16
16
  end
17
17
 
@@ -22,11 +22,11 @@ describe "when creating a model with an embedded model" do
22
22
  end
23
23
 
24
24
  it "does not have changes in the embedded model" do
25
- person.pet.changes.should be_empty
25
+ expect(person.pet.changes).to be_empty
26
26
  end
27
27
 
28
28
  it "has previous_changes in the embedded model" do
29
- person.pet.previous_changes.should_not be_empty
29
+ expect(person.pet.previous_changes).to_not be_empty
30
30
  end
31
31
  end
32
32
 
@@ -41,11 +41,11 @@ describe "when embedding a model on an already saved model" do
41
41
  end
42
42
 
43
43
  it "has not changes on the embedded model" do
44
- person.pet.changes.should be_empty
44
+ expect(person.pet.changes).to be_empty
45
45
  end
46
46
 
47
47
  it "has previous changes on the embedded model" do
48
- person.pet.previous_changes.should_not be_empty
48
+ expect(person.pet.previous_changes).to_not be_empty
49
49
  end
50
50
 
51
51
  describe "and saving the model" do
@@ -55,11 +55,11 @@ describe "when embedding a model on an already saved model" do
55
55
  end
56
56
 
57
57
  it "does not have changes on the embedded model" do
58
- person.pet.changes.should be_empty
58
+ expect(person.pet.changes).to be_empty
59
59
  end
60
60
 
61
61
  it "does not have previous changes on the embedded model" do
62
- person.pet.previous_changes.should be_empty
62
+ expect(person.pet.previous_changes).to be_empty
63
63
  end
64
64
  end
65
65
  end
@@ -25,14 +25,14 @@ describe Mongoid::Relations::Embedded::In do
25
25
  context "when the document is a different instance" do
26
26
 
27
27
  it "returns false" do
28
- (relation === Person.new).should be_false
28
+ expect((relation === Person.new)).to be false
29
29
  end
30
30
  end
31
31
 
32
32
  context "when the document is the same instance" do
33
33
 
34
34
  it "returns true" do
35
- (relation === target).should be_true
35
+ expect((relation === target)).to be true
36
36
  end
37
37
  end
38
38
  end
@@ -57,19 +57,19 @@ describe Mongoid::Relations::Embedded::In do
57
57
  end
58
58
 
59
59
  it "sets the target of the relation" do
60
- name.namable.should eq(person)
60
+ expect(name.namable).to eq(person)
61
61
  end
62
62
 
63
63
  it "sets the base on the inverse relation" do
64
- person.name.should eq(name)
64
+ expect(person.name).to eq(name)
65
65
  end
66
66
 
67
67
  it "sets the same instance on the inverse relation" do
68
- person.name.should eql(name)
68
+ expect(person.name).to eql(name)
69
69
  end
70
70
 
71
71
  it "does not save the target" do
72
- person.should_not be_persisted
72
+ expect(person).to_not be_persisted
73
73
  end
74
74
  end
75
75
 
@@ -88,19 +88,19 @@ describe Mongoid::Relations::Embedded::In do
88
88
  end
89
89
 
90
90
  it "sets the target of the relation" do
91
- name.namable.should eq(person)
91
+ expect(name.namable).to eq(person)
92
92
  end
93
93
 
94
94
  it "sets the base on the inverse relation" do
95
- person.name.should eq(name)
95
+ expect(person.name).to eq(name)
96
96
  end
97
97
 
98
98
  it "sets the same instance on the inverse relation" do
99
- person.name.should eql(name)
99
+ expect(person.name).to eql(name)
100
100
  end
101
101
 
102
102
  it "does not save the base" do
103
- name.should_not be_persisted
103
+ expect(name).to_not be_persisted
104
104
  end
105
105
  end
106
106
  end
@@ -122,19 +122,19 @@ describe Mongoid::Relations::Embedded::In do
122
122
  end
123
123
 
124
124
  it "sets the target of the relation" do
125
- address.addressable.should eq(person)
125
+ expect(address.addressable).to eq(person)
126
126
  end
127
127
 
128
128
  it "appends the base on the inverse relation" do
129
- person.addresses.should eq([ address ])
129
+ expect(person.addresses).to eq([ address ])
130
130
  end
131
131
 
132
132
  it "sets the same instance in the inverse relation" do
133
- person.addresses.first.should eql(address)
133
+ expect(person.addresses.first).to eql(address)
134
134
  end
135
135
 
136
136
  it "does not save the target" do
137
- person.should_not be_persisted
137
+ expect(person).to_not be_persisted
138
138
  end
139
139
  end
140
140
 
@@ -153,15 +153,15 @@ describe Mongoid::Relations::Embedded::In do
153
153
  end
154
154
 
155
155
  it "sets the target of the relation" do
156
- address.addressable.should eq(person)
156
+ expect(address.addressable).to eq(person)
157
157
  end
158
158
 
159
159
  it "sets the same instance in the inverse relation" do
160
- person.addresses.first.should eql(address)
160
+ expect(person.addresses.first).to eql(address)
161
161
  end
162
162
 
163
163
  it "appends the base on the inverse relation" do
164
- person.addresses.should eq([ address ])
164
+ expect(person.addresses).to eq([ address ])
165
165
  end
166
166
  end
167
167
  end
@@ -187,11 +187,11 @@ describe Mongoid::Relations::Embedded::In do
187
187
  end
188
188
 
189
189
  it "sets the relation to nil" do
190
- name.namable.should be_nil
190
+ expect(name.namable).to be_nil
191
191
  end
192
192
 
193
193
  it "removes the inverse relation" do
194
- person.name.should be_nil
194
+ expect(person.name).to be_nil
195
195
  end
196
196
  end
197
197
 
@@ -210,11 +210,11 @@ describe Mongoid::Relations::Embedded::In do
210
210
  end
211
211
 
212
212
  it "sets the relation to nil" do
213
- name.namable.should be_nil
213
+ expect(name.namable).to be_nil
214
214
  end
215
215
 
216
216
  it "removes the inverse relation" do
217
- person.name.should be_nil
217
+ expect(person.name).to be_nil
218
218
  end
219
219
  end
220
220
 
@@ -234,15 +234,15 @@ describe Mongoid::Relations::Embedded::In do
234
234
  end
235
235
 
236
236
  it "sets the relation to nil" do
237
- name.namable.should be_nil
237
+ expect(name.namable).to be_nil
238
238
  end
239
239
 
240
240
  it "removed the inverse relation" do
241
- person.name.should be_nil
241
+ expect(person.name).to be_nil
242
242
  end
243
243
 
244
244
  it "deletes the child document" do
245
- name.should be_destroyed
245
+ expect(name).to be_destroyed
246
246
  end
247
247
  end
248
248
  end
@@ -265,11 +265,11 @@ describe Mongoid::Relations::Embedded::In do
265
265
  end
266
266
 
267
267
  it "sets the relation to nil" do
268
- address.addressable.should be_nil
268
+ expect(address.addressable).to be_nil
269
269
  end
270
270
 
271
271
  it "removes the inverse relation" do
272
- person.addresses.should be_empty
272
+ expect(person.addresses).to be_empty
273
273
  end
274
274
  end
275
275
 
@@ -284,7 +284,7 @@ describe Mongoid::Relations::Embedded::In do
284
284
  end
285
285
 
286
286
  it "sets the relation to nil" do
287
- address.addressable.should be_nil
287
+ expect(address.addressable).to be_nil
288
288
  end
289
289
  end
290
290
 
@@ -304,15 +304,15 @@ describe Mongoid::Relations::Embedded::In do
304
304
  end
305
305
 
306
306
  it "sets the relation to nil" do
307
- address.addressable.should be_nil
307
+ expect(address.addressable).to be_nil
308
308
  end
309
309
 
310
310
  it "removed the inverse relation" do
311
- person.addresses.should be_empty
311
+ expect(person.addresses).to be_empty
312
312
  end
313
313
 
314
314
  it "deletes the child document" do
315
- address.should be_destroyed
315
+ expect(address).to be_destroyed
316
316
  end
317
317
  end
318
318
 
@@ -336,19 +336,19 @@ describe Mongoid::Relations::Embedded::In do
336
336
  end
337
337
 
338
338
  it "sets the relation to nil" do
339
- address_one.addressable.should be_nil
339
+ expect(address_one.addressable).to be_nil
340
340
  end
341
341
 
342
342
  it "removed the inverse relation" do
343
- person.addresses.should eq([ address_two ])
343
+ expect(person.addresses).to eq([ address_two ])
344
344
  end
345
345
 
346
346
  it "deletes the child document" do
347
- address_one.should be_destroyed
347
+ expect(address_one).to be_destroyed
348
348
  end
349
349
 
350
350
  it "reindexes the children" do
351
- address_two._index.should eq(0)
351
+ expect(address_two._index).to eq(0)
352
352
  end
353
353
  end
354
354
  end
@@ -373,28 +373,28 @@ describe Mongoid::Relations::Embedded::In do
373
373
  end
374
374
 
375
375
  it "returns the embedded one builder" do
376
- described_class.builder(base, metadata, target).should be_a(builder_klass)
376
+ expect(described_class.builder(base, metadata, target)).to be_a(builder_klass)
377
377
  end
378
378
  end
379
379
 
380
380
  describe ".embedded?" do
381
381
 
382
382
  it "returns true" do
383
- described_class.should be_embedded
383
+ expect(described_class).to be_embedded
384
384
  end
385
385
  end
386
386
 
387
387
  describe ".foreign_key_suffix" do
388
388
 
389
389
  it "returns nil" do
390
- described_class.foreign_key_suffix.should be_nil
390
+ expect(described_class.foreign_key_suffix).to be_nil
391
391
  end
392
392
  end
393
393
 
394
394
  describe ".macro" do
395
395
 
396
396
  it "returns embeds_one" do
397
- described_class.macro.should eq(:embedded_in)
397
+ expect(described_class.macro).to eq(:embedded_in)
398
398
  end
399
399
  end
400
400
 
@@ -413,8 +413,7 @@ describe Mongoid::Relations::Embedded::In do
413
413
  end
414
414
 
415
415
  it "returns the single nested builder" do
416
- described_class.nested_builder(metadata, attributes, {}).should
417
- be_a(nested_builder_klass)
416
+ expect(described_class.nested_builder(metadata, attributes, {})).to be_a(nested_builder_klass)
418
417
  end
419
418
  end
420
419
 
@@ -437,7 +436,7 @@ describe Mongoid::Relations::Embedded::In do
437
436
  context "when checking #{method}" do
438
437
 
439
438
  it "returns true" do
440
- document.respond_to?(method).should be_true
439
+ expect(document.respond_to?(method)).to be true
441
440
  end
442
441
  end
443
442
  end
@@ -446,7 +445,7 @@ describe Mongoid::Relations::Embedded::In do
446
445
  describe ".valid_options" do
447
446
 
448
447
  it "returns the valid options" do
449
- described_class.valid_options.should eq(
448
+ expect(described_class.valid_options).to eq(
450
449
  [ :autobuild, :cyclic, :polymorphic ]
451
450
  )
452
451
  end
@@ -455,7 +454,7 @@ describe Mongoid::Relations::Embedded::In do
455
454
  describe ".validation_default" do
456
455
 
457
456
  it "returns false" do
458
- described_class.validation_default.should be_false
457
+ expect(described_class.validation_default).to be false
459
458
  end
460
459
  end
461
460
 
@@ -478,23 +477,23 @@ describe Mongoid::Relations::Embedded::In do
478
477
  end
479
478
 
480
479
  it "saves the child" do
481
- Person.last.addresses.last.should eq(address)
480
+ expect(Person.last.addresses.last).to eq(address)
482
481
  end
483
482
 
484
483
  it "indexes the child" do
485
- address._index.should eq(0)
484
+ expect(address._index).to eq(0)
486
485
  end
487
486
 
488
487
  it "saves the first location with the correct index" do
489
- first_location._index.should eq(0)
488
+ expect(first_location._index).to eq(0)
490
489
  end
491
490
 
492
491
  it "saves the second location with the correct index" do
493
- second_location._index.should eq(1)
492
+ expect(second_location._index).to eq(1)
494
493
  end
495
494
 
496
495
  it "has the locations in the association array" do
497
- Person.last.addresses.last.locations.should eq(
496
+ expect(Person.last.addresses.last.locations).to eq(
498
497
  [first_location, second_location]
499
498
  )
500
499
  end
@@ -515,11 +514,11 @@ describe Mongoid::Relations::Embedded::In do
515
514
  end
516
515
 
517
516
  it "does not save the child" do
518
- address.should_not be_persisted
517
+ expect(address).to_not be_persisted
519
518
  end
520
519
 
521
520
  it "does not save the deeply embedded children" do
522
- address.locations.first.should_not be_persisted
521
+ expect(address.locations.first).to_not be_persisted
523
522
  end
524
523
  end
525
524
 
@@ -547,15 +546,15 @@ describe Mongoid::Relations::Embedded::In do
547
546
  end
548
547
 
549
548
  it "sets the new parent" do
550
- name.namable.should eq(person)
549
+ expect(name.namable).to eq(person)
551
550
  end
552
551
 
553
552
  it "removes the previous parent relation" do
554
- person_two.name.should be_nil
553
+ expect(person_two.name).to be_nil
555
554
  end
556
555
 
557
556
  it "sets the new child relation" do
558
- person.name.should eq(name)
557
+ expect(person.name).to eq(name)
559
558
  end
560
559
 
561
560
  context "when reloading" do
@@ -565,15 +564,15 @@ describe Mongoid::Relations::Embedded::In do
565
564
  end
566
565
 
567
566
  it "sets the new parent" do
568
- name.namable.should eq(person)
567
+ expect(name.namable).to eq(person)
569
568
  end
570
569
 
571
570
  it "removes the previous parent relation" do
572
- person_two.name.should be_nil
571
+ expect(person_two.name).to be_nil
573
572
  end
574
573
 
575
574
  it "sets the new child relation" do
576
- person.name.should eq(name)
575
+ expect(person.name).to eq(name)
577
576
  end
578
577
  end
579
578
  end
@@ -21,35 +21,35 @@ describe Mongoid::Relations::Embedded::Many do
21
21
  end
22
22
 
23
23
  it "appends to the target" do
24
- person.addresses.should eq([ address ])
24
+ expect(person.addresses).to eq([ address ])
25
25
  end
26
26
 
27
27
  it "sets the base on the inverse relation" do
28
- address.addressable.should eq(person)
28
+ expect(address.addressable).to eq(person)
29
29
  end
30
30
 
31
31
  it "sets the same instance on the inverse relation" do
32
- address.addressable.should eql(person)
32
+ expect(address.addressable).to eql(person)
33
33
  end
34
34
 
35
35
  it "does not save the new document" do
36
- address.should_not be_persisted
36
+ expect(address).to_not be_persisted
37
37
  end
38
38
 
39
39
  it "sets the parent on the child" do
40
- address._parent.should eq(person)
40
+ expect(address._parent).to eq(person)
41
41
  end
42
42
 
43
43
  it "sets the metadata on the child" do
44
- address.metadata.should_not be_nil
44
+ expect(address.metadata).to_not be_nil
45
45
  end
46
46
 
47
47
  it "sets the index on the child" do
48
- address._index.should eq(0)
48
+ expect(address._index).to eq(0)
49
49
  end
50
50
 
51
51
  it "returns the relation" do
52
- added.should eq(person.addresses)
52
+ expect(added).to eq(person.addresses)
53
53
  end
54
54
 
55
55
  context "with a limiting default scope" do
@@ -65,11 +65,11 @@ describe Mongoid::Relations::Embedded::Many do
65
65
  end
66
66
 
67
67
  it "appends to the target" do
68
- person.appointments.target.should eq([ active ])
68
+ expect(person.appointments.target).to eq([ active ])
69
69
  end
70
70
 
71
71
  it "appends to the _unscoped" do
72
- person.appointments.send(:_unscoped).should eq([ active ])
72
+ expect(person.appointments.send(:_unscoped)).to eq([ active ])
73
73
  end
74
74
  end
75
75
 
@@ -84,11 +84,11 @@ describe Mongoid::Relations::Embedded::Many do
84
84
  end
85
85
 
86
86
  it "doesn't append to the target" do
87
- person.appointments.target.should_not eq([ inactive ])
87
+ expect(person.appointments.target).to_not eq([ inactive ])
88
88
  end
89
89
 
90
90
  it "appends to the _unscoped" do
91
- person.appointments.send(:_unscoped).should eq([ inactive ])
91
+ expect(person.appointments.send(:_unscoped)).to eq([ inactive ])
92
92
  end
93
93
  end
94
94
  end
@@ -109,7 +109,7 @@ describe Mongoid::Relations::Embedded::Many do
109
109
  end
110
110
 
111
111
  it "saves the new document" do
112
- address.should be_persisted
112
+ expect(address).to be_persisted
113
113
  end
114
114
  end
115
115
 
@@ -132,15 +132,15 @@ describe Mongoid::Relations::Embedded::Many do
132
132
  end
133
133
 
134
134
  it "saves the first document" do
135
- address_one.should be_persisted
135
+ expect(address_one).to be_persisted
136
136
  end
137
137
 
138
138
  it "saves the second document" do
139
- address_two.should be_persisted
139
+ expect(address_two).to be_persisted
140
140
  end
141
141
 
142
142
  it "returns the relation" do
143
- added.should eq(person.addresses)
143
+ expect(added).to eq(person.addresses)
144
144
  end
145
145
  end
146
146
 
@@ -161,31 +161,31 @@ describe Mongoid::Relations::Embedded::Many do
161
161
  end
162
162
 
163
163
  it "appends to the target" do
164
- parent_role.child_roles.should eq([ child_role ])
164
+ expect(parent_role.child_roles).to eq([ child_role ])
165
165
  end
166
166
 
167
167
  it "sets the base on the inverse relation" do
168
- child_role.parent_role.should eq(parent_role)
168
+ expect(child_role.parent_role).to eq(parent_role)
169
169
  end
170
170
 
171
171
  it "sets the same instance on the inverse relation" do
172
- child_role.parent_role.should eql(parent_role)
172
+ expect(child_role.parent_role).to eql(parent_role)
173
173
  end
174
174
 
175
175
  it "does not save the new document" do
176
- child_role.should_not be_persisted
176
+ expect(child_role).to_not be_persisted
177
177
  end
178
178
 
179
179
  it "sets the parent on the child" do
180
- child_role._parent.should eq(parent_role)
180
+ expect(child_role._parent).to eq(parent_role)
181
181
  end
182
182
 
183
183
  it "sets the metadata on the child" do
184
- child_role.metadata.should_not be_nil
184
+ expect(child_role.metadata).to_not be_nil
185
185
  end
186
186
 
187
187
  it "sets the index on the child" do
188
- child_role._index.should eq(0)
188
+ expect(child_role._index).to eq(0)
189
189
  end
190
190
  end
191
191
 
@@ -204,7 +204,7 @@ describe Mongoid::Relations::Embedded::Many do
204
204
  end
205
205
 
206
206
  it "saves the new document" do
207
- child_role.should be_persisted
207
+ expect(child_role).to be_persisted
208
208
  end
209
209
  end
210
210
  end
@@ -228,35 +228,35 @@ describe Mongoid::Relations::Embedded::Many do
228
228
  end
229
229
 
230
230
  it "sets the target of the relation" do
231
- person.addresses.should eq([ address ])
231
+ expect(person.addresses).to eq([ address ])
232
232
  end
233
233
 
234
234
  it "sets the _unscoped of the relation" do
235
- person.addresses.send(:_unscoped).should eq([ address ])
235
+ expect(person.addresses.send(:_unscoped)).to eq([ address ])
236
236
  end
237
237
 
238
238
  it "sets the base on the inverse relation" do
239
- address.addressable.should eq(person)
239
+ expect(address.addressable).to eq(person)
240
240
  end
241
241
 
242
242
  it "sets the same instance on the inverse relation" do
243
- address.addressable.should eql(person)
243
+ expect(address.addressable).to eql(person)
244
244
  end
245
245
 
246
246
  it "does not save the target" do
247
- address.should_not be_persisted
247
+ expect(address).to_not be_persisted
248
248
  end
249
249
 
250
250
  it "sets the parent on the child" do
251
- address._parent.should eq(person)
251
+ expect(address._parent).to eq(person)
252
252
  end
253
253
 
254
254
  it "sets the metadata on the child" do
255
- address.metadata.should_not be_nil
255
+ expect(address.metadata).to_not be_nil
256
256
  end
257
257
 
258
258
  it "sets the index on the child" do
259
- address._index.should eq(0)
259
+ expect(address._index).to eq(0)
260
260
  end
261
261
  end
262
262
 
@@ -277,7 +277,7 @@ describe Mongoid::Relations::Embedded::Many do
277
277
  end
278
278
 
279
279
  it "saves the target" do
280
- address.should be_persisted
280
+ expect(address).to be_persisted
281
281
  end
282
282
  end
283
283
 
@@ -300,7 +300,7 @@ describe Mongoid::Relations::Embedded::Many do
300
300
  end
301
301
 
302
302
  it "overwrites the existing addresses" do
303
- person.reload.addresses.should eq([ new_address ])
303
+ expect(person.reload.addresses).to eq([ new_address ])
304
304
  end
305
305
  end
306
306
 
@@ -311,11 +311,11 @@ describe Mongoid::Relations::Embedded::Many do
311
311
  end
312
312
 
313
313
  it "sets the relation" do
314
- person.addresses.should eq([ address ])
314
+ expect(person.addresses).to eq([ address ])
315
315
  end
316
316
 
317
317
  it "does not save the target" do
318
- address.should_not be_persisted
318
+ expect(address).to_not be_persisted
319
319
  end
320
320
 
321
321
  context "when setting the relation multiple times" do
@@ -330,11 +330,11 @@ describe Mongoid::Relations::Embedded::Many do
330
330
  end
331
331
 
332
332
  it "sets the new documents" do
333
- person.addresses.should eq([ address_two ])
333
+ expect(person.addresses).to eq([ address_two ])
334
334
  end
335
335
 
336
336
  it "persits only the new documents" do
337
- person.reload.addresses.should eq([ address_two ])
337
+ expect(person.reload.addresses).to eq([ address_two ])
338
338
  end
339
339
  end
340
340
  end
@@ -364,11 +364,11 @@ describe Mongoid::Relations::Embedded::Many do
364
364
  end
365
365
 
366
366
  it "sets the documents" do
367
- doctor.addresses.should eq([ address_one ])
367
+ expect(doctor.addresses).to eq([ address_one ])
368
368
  end
369
369
 
370
370
  it "persists the document" do
371
- doctor.reload.addresses.should eq([ address_one ])
371
+ expect(doctor.reload.addresses).to eq([ address_one ])
372
372
  end
373
373
 
374
374
  context "when setting the relation multiple times" do
@@ -383,11 +383,11 @@ describe Mongoid::Relations::Embedded::Many do
383
383
  end
384
384
 
385
385
  it "sets the new documents" do
386
- doctor.addresses.should eq([ address_two ])
386
+ expect(doctor.addresses).to eq([ address_two ])
387
387
  end
388
388
 
389
389
  it "persits only the new documents" do
390
- doctor.reload.addresses.should eq([ address_two ])
390
+ expect(doctor.reload.addresses).to eq([ address_two ])
391
391
  end
392
392
  end
393
393
  end
@@ -412,7 +412,7 @@ describe Mongoid::Relations::Embedded::Many do
412
412
  end
413
413
 
414
414
  it "deletes the old documents" do
415
- person.reload.addresses.should eq([ address ])
415
+ expect(person.reload.addresses).to eq([ address ])
416
416
  end
417
417
  end
418
418
 
@@ -434,7 +434,6 @@ describe Mongoid::Relations::Embedded::Many do
434
434
  field :old_state, type: String
435
435
  field :new_state, type: String
436
436
  field :when_changed, type: DateTime
437
- attr_protected :_id
438
437
  embedded_in :tracking_id, class_name: "MyCompany::Model::TrackingId"
439
438
  end
440
439
  end
@@ -453,15 +452,15 @@ describe Mongoid::Relations::Embedded::Many do
453
452
  end
454
453
 
455
454
  it "allows creation of the embedded document" do
456
- tracking_id.validation_history.size.should eq(1)
455
+ expect(tracking_id.validation_history.size).to eq(1)
457
456
  end
458
457
 
459
458
  it "saves the relation" do
460
- history.should be_persisted
459
+ expect(history).to be_persisted
461
460
  end
462
461
 
463
462
  it "remains on reload" do
464
- tracking_id.reload.validation_history.size.should eq(1)
463
+ expect(tracking_id.reload.validation_history.size).to eq(1)
465
464
  end
466
465
  end
467
466
 
@@ -480,7 +479,7 @@ describe Mongoid::Relations::Embedded::Many do
480
479
  end
481
480
 
482
481
  it "requires an inflection to determine the class" do
483
- slave.reload.address_numbers.size.should eq(1)
482
+ expect(slave.reload.address_numbers.size).to eq(1)
484
483
  end
485
484
  end
486
485
 
@@ -510,11 +509,11 @@ describe Mongoid::Relations::Embedded::Many do
510
509
  end
511
510
 
512
511
  it "sets the new attributes" do
513
- person.addresses.first.city.should eq("Berlin")
512
+ expect(person.addresses.first.city).to eq("Berlin")
514
513
  end
515
514
 
516
515
  it "persists the changes" do
517
- person.reload.addresses.first.city.should eq("Berlin")
516
+ expect(person.reload.addresses.first.city).to eq("Berlin")
518
517
  end
519
518
  end
520
519
  end
@@ -546,23 +545,23 @@ describe Mongoid::Relations::Embedded::Many do
546
545
  end
547
546
 
548
547
  it "sets the new attributes on the address" do
549
- person.addresses.first.city.should eq("Berlin")
548
+ expect(person.addresses.first.city).to eq("Berlin")
550
549
  end
551
550
 
552
551
  it "sets the new attributes on the location" do
553
- person.addresses.first.locations.first.name.should eq("Home")
552
+ expect(person.addresses.first.locations.first.name).to eq("Home")
554
553
  end
555
554
 
556
555
  it "persists the changes to the address" do
557
- person.reload.addresses.first.city.should eq("Berlin")
556
+ expect(person.reload.addresses.first.city).to eq("Berlin")
558
557
  end
559
558
 
560
559
  it "persists the changes to the location" do
561
- person.reload.addresses.first.locations.first.name.should eq("Home")
560
+ expect(person.reload.addresses.first.locations.first.name).to eq("Home")
562
561
  end
563
562
 
564
563
  it "does not persist the locations collection to the person document" do
565
- person.reload[:locations].should be_nil
564
+ expect(person.reload[:locations]).to be_nil
566
565
  end
567
566
  end
568
567
  end
@@ -584,31 +583,31 @@ describe Mongoid::Relations::Embedded::Many do
584
583
  end
585
584
 
586
585
  it "sets the target of the relation" do
587
- parent_role.child_roles.should eq([ child_role ])
586
+ expect(parent_role.child_roles).to eq([ child_role ])
588
587
  end
589
588
 
590
589
  it "sets the base on the inverse relation" do
591
- child_role.parent_role.should eq(parent_role)
590
+ expect(child_role.parent_role).to eq(parent_role)
592
591
  end
593
592
 
594
593
  it "sets the same instance on the inverse relation" do
595
- child_role.parent_role.should eql(parent_role)
594
+ expect(child_role.parent_role).to eql(parent_role)
596
595
  end
597
596
 
598
597
  it "does not save the target" do
599
- child_role.should_not be_persisted
598
+ expect(child_role).to_not be_persisted
600
599
  end
601
600
 
602
601
  it "sets the parent on the child" do
603
- child_role._parent.should eq(parent_role)
602
+ expect(child_role._parent).to eq(parent_role)
604
603
  end
605
604
 
606
605
  it "sets the metadata on the child" do
607
- child_role.metadata.should_not be_nil
606
+ expect(child_role.metadata).to_not be_nil
608
607
  end
609
608
 
610
609
  it "sets the index on the child" do
611
- child_role._index.should eq(0)
610
+ expect(child_role._index).to eq(0)
612
611
  end
613
612
  end
614
613
 
@@ -627,7 +626,7 @@ describe Mongoid::Relations::Embedded::Many do
627
626
  end
628
627
 
629
628
  it "saves the target" do
630
- child_role.should be_persisted
629
+ expect(child_role).to be_persisted
631
630
  end
632
631
  end
633
632
  end
@@ -653,15 +652,15 @@ describe Mongoid::Relations::Embedded::Many do
653
652
  end
654
653
 
655
654
  it "sets the relation to empty" do
656
- person.addresses.should be_empty
655
+ expect(person.addresses).to be_empty
657
656
  end
658
657
 
659
658
  it "sets the unscoped to empty" do
660
- person.addresses.send(:_unscoped).should be_empty
659
+ expect(person.addresses.send(:_unscoped)).to be_empty
661
660
  end
662
661
 
663
662
  it "removes the inverse relation" do
664
- address.addressable.should be_nil
663
+ expect(address.addressable).to be_nil
665
664
  end
666
665
  end
667
666
 
@@ -676,7 +675,7 @@ describe Mongoid::Relations::Embedded::Many do
676
675
  end
677
676
 
678
677
  it "sets the relation to empty" do
679
- person.addresses.should be_empty
678
+ expect(person.addresses).to be_empty
680
679
  end
681
680
  end
682
681
 
@@ -698,19 +697,19 @@ describe Mongoid::Relations::Embedded::Many do
698
697
  end
699
698
 
700
699
  it "sets the relation to empty" do
701
- person.addresses.should be_empty
700
+ expect(person.addresses).to be_empty
702
701
  end
703
702
 
704
703
  it "sets the relation to empty in the database" do
705
- person.reload.addresses.should be_empty
704
+ expect(person.reload.addresses).to be_empty
706
705
  end
707
706
 
708
707
  it "removed the inverse relation" do
709
- address.addressable.should be_nil
708
+ expect(address.addressable).to be_nil
710
709
  end
711
710
 
712
711
  it "deletes the child document" do
713
- address.should be_destroyed
712
+ expect(address).to be_destroyed
714
713
  end
715
714
  end
716
715
 
@@ -722,11 +721,11 @@ describe Mongoid::Relations::Embedded::Many do
722
721
  end
723
722
 
724
723
  it "sets the relation to empty" do
725
- person.addresses.should be_empty
724
+ expect(person.addresses).to be_empty
726
725
  end
727
726
 
728
727
  it "deletes the child document" do
729
- address.should be_destroyed
728
+ expect(address).to be_destroyed
730
729
  end
731
730
 
732
731
  context "when saving the parent" do
@@ -737,7 +736,7 @@ describe Mongoid::Relations::Embedded::Many do
737
736
  end
738
737
 
739
738
  it "persists the deletion" do
740
- person.addresses.should be_empty
739
+ expect(person.addresses).to be_empty
741
740
  end
742
741
  end
743
742
  end
@@ -763,11 +762,11 @@ describe Mongoid::Relations::Embedded::Many do
763
762
  end
764
763
 
765
764
  it "sets the relation to empty" do
766
- person.addresses.should be_empty
765
+ expect(person.addresses).to be_empty
767
766
  end
768
767
 
769
768
  it "sets the relation to empty in the database" do
770
- reloaded.addresses.should be_empty
769
+ expect(reloaded.addresses).to be_empty
771
770
  end
772
771
  end
773
772
  end
@@ -790,11 +789,11 @@ describe Mongoid::Relations::Embedded::Many do
790
789
  end
791
790
 
792
791
  it "sets the relation to empty" do
793
- parent_role.child_roles.should be_empty
792
+ expect(parent_role.child_roles).to be_empty
794
793
  end
795
794
 
796
795
  it "removes the inverse relation" do
797
- child_role.parent_role.should be_nil
796
+ expect(child_role.parent_role).to be_nil
798
797
  end
799
798
  end
800
799
 
@@ -809,7 +808,7 @@ describe Mongoid::Relations::Embedded::Many do
809
808
  end
810
809
 
811
810
  it "sets the relation to empty" do
812
- parent_role.child_roles.should be_empty
811
+ expect(parent_role.child_roles).to be_empty
813
812
  end
814
813
  end
815
814
 
@@ -829,15 +828,15 @@ describe Mongoid::Relations::Embedded::Many do
829
828
  end
830
829
 
831
830
  it "sets the relation to empty" do
832
- parent_role.child_roles.should be_empty
831
+ expect(parent_role.child_roles).to be_empty
833
832
  end
834
833
 
835
834
  it "removed the inverse relation" do
836
- child_role.parent_role.should be_nil
835
+ expect(child_role.parent_role).to be_nil
837
836
  end
838
837
 
839
838
  it "deletes the child document" do
840
- child_role.should be_destroyed
839
+ expect(child_role).to be_destroyed
841
840
  end
842
841
  end
843
842
  end
@@ -860,7 +859,7 @@ describe Mongoid::Relations::Embedded::Many do
860
859
  end
861
860
 
862
861
  it "returns the documents as an array of hashes" do
863
- document.should eq([ address.as_document ])
862
+ expect(document).to eq([ address.as_document ])
864
863
  end
865
864
  end
866
865
 
@@ -885,7 +884,7 @@ describe Mongoid::Relations::Embedded::Many do
885
884
  end
886
885
 
887
886
  it "returns the unscoped documents as an array of hashes" do
888
- document.should eq([ headache.as_document, cough.as_document ])
887
+ expect(document).to eq([ headache.as_document, cough.as_document ])
889
888
  end
890
889
  end
891
890
 
@@ -908,7 +907,7 @@ describe Mongoid::Relations::Embedded::Many do
908
907
  end
909
908
 
910
909
  it "returns the unscoped documents as an array of hashes" do
911
- document.should eq([ active.as_document, inactive.as_document ])
910
+ expect(document).to eq([ active.as_document, inactive.as_document ])
912
911
  end
913
912
  end
914
913
  end
@@ -918,28 +917,6 @@ describe Mongoid::Relations::Embedded::Many do
918
917
 
919
918
  describe "#build" do
920
919
 
921
- context "when providing scoped mass assignment" do
922
-
923
- let(:person) do
924
- Person.new
925
- end
926
-
927
- let(:video) do
928
- person.videos.send(
929
- method,
930
- { title: "Inception", year: 1999 }, as: :admin
931
- )
932
- end
933
-
934
- it "sets the attributes for the provided role" do
935
- video.title.should eq("Inception")
936
- end
937
-
938
- it "does not set the attributes for other roles" do
939
- video.year.should be_nil
940
- end
941
- end
942
-
943
920
  context "when the relation is not cyclic" do
944
921
 
945
922
  let(:person) do
@@ -953,39 +930,39 @@ describe Mongoid::Relations::Embedded::Many do
953
930
  end
954
931
 
955
932
  it "appends to the target" do
956
- person.addresses.should eq([ address ])
933
+ expect(person.addresses).to eq([ address ])
957
934
  end
958
935
 
959
936
  it "appends to the unscoped" do
960
- person.addresses.send(:_unscoped).should eq([ address ])
937
+ expect(person.addresses.send(:_unscoped)).to eq([ address ])
961
938
  end
962
939
 
963
940
  it "sets the base on the inverse relation" do
964
- address.addressable.should eq(person)
941
+ expect(address.addressable).to eq(person)
965
942
  end
966
943
 
967
944
  it "does not save the new document" do
968
- address.should_not be_persisted
945
+ expect(address).to_not be_persisted
969
946
  end
970
947
 
971
948
  it "sets the parent on the child" do
972
- address._parent.should eq(person)
949
+ expect(address._parent).to eq(person)
973
950
  end
974
951
 
975
952
  it "sets the metadata on the child" do
976
- address.metadata.should_not be_nil
953
+ expect(address.metadata).to_not be_nil
977
954
  end
978
955
 
979
956
  it "sets the index on the child" do
980
- address._index.should eq(0)
957
+ expect(address._index).to eq(0)
981
958
  end
982
959
 
983
960
  it "writes to the attributes" do
984
- address.street.should eq("Bond")
961
+ expect(address.street).to eq("Bond")
985
962
  end
986
963
 
987
964
  it "calls the passed block" do
988
- address.state.should eq("CA")
965
+ expect(address.state).to eq("CA")
989
966
  end
990
967
  end
991
968
 
@@ -1000,31 +977,31 @@ describe Mongoid::Relations::Embedded::Many do
1000
977
  end
1001
978
 
1002
979
  it "appends to the target" do
1003
- parent_role.child_roles.should eq([ child_role ])
980
+ expect(parent_role.child_roles).to eq([ child_role ])
1004
981
  end
1005
982
 
1006
983
  it "sets the base on the inverse relation" do
1007
- child_role.parent_role.should eq(parent_role)
984
+ expect(child_role.parent_role).to eq(parent_role)
1008
985
  end
1009
986
 
1010
987
  it "does not save the new document" do
1011
- child_role.should_not be_persisted
988
+ expect(child_role).to_not be_persisted
1012
989
  end
1013
990
 
1014
991
  it "sets the parent on the child" do
1015
- child_role._parent.should eq(parent_role)
992
+ expect(child_role._parent).to eq(parent_role)
1016
993
  end
1017
994
 
1018
995
  it "sets the metadata on the child" do
1019
- child_role.metadata.should_not be_nil
996
+ expect(child_role.metadata).to_not be_nil
1020
997
  end
1021
998
 
1022
999
  it "sets the index on the child" do
1023
- child_role._index.should eq(0)
1000
+ expect(child_role._index).to eq(0)
1024
1001
  end
1025
1002
 
1026
1003
  it "writes to the attributes" do
1027
- child_role.name.should eq("CTO")
1004
+ expect(child_role.name).to eq("CTO")
1028
1005
  end
1029
1006
  end
1030
1007
 
@@ -1053,7 +1030,7 @@ describe Mongoid::Relations::Embedded::Many do
1053
1030
  end
1054
1031
 
1055
1032
  it "persists the deeply embedded document" do
1056
- location.name.should eq("Home")
1033
+ expect(location.name).to eq("Home")
1057
1034
  end
1058
1035
  end
1059
1036
  end
@@ -1083,8 +1060,9 @@ describe Mongoid::Relations::Embedded::Many do
1083
1060
  end
1084
1061
 
1085
1062
  it "returns the many builder" do
1086
- described_class.builder(base, metadata, document).should
1087
- be_a(Mongoid::Relations::Builders::Embedded::Many)
1063
+ expect(
1064
+ described_class.builder(base, metadata, document)
1065
+ ).to be_a(Mongoid::Relations::Builders::Embedded::Many)
1088
1066
  end
1089
1067
  end
1090
1068
 
@@ -1107,23 +1085,23 @@ describe Mongoid::Relations::Embedded::Many do
1107
1085
  end
1108
1086
 
1109
1087
  it "clears out the relation" do
1110
- person.addresses.should be_empty
1088
+ expect(person.addresses).to be_empty
1111
1089
  end
1112
1090
 
1113
1091
  it "clears the unscoped" do
1114
- person.addresses.send(:_unscoped).should be_empty
1092
+ expect(person.addresses.send(:_unscoped)).to be_empty
1115
1093
  end
1116
1094
 
1117
1095
  it "marks the documents as deleted" do
1118
- address.should be_destroyed
1096
+ expect(address).to be_destroyed
1119
1097
  end
1120
1098
 
1121
1099
  it "deletes the documents from the db" do
1122
- person.reload.addresses.should be_empty
1100
+ expect(person.reload.addresses).to be_empty
1123
1101
  end
1124
1102
 
1125
1103
  it "returns the relation" do
1126
- relation.should be_empty
1104
+ expect(relation).to be_empty
1127
1105
  end
1128
1106
  end
1129
1107
 
@@ -1138,7 +1116,7 @@ describe Mongoid::Relations::Embedded::Many do
1138
1116
  end
1139
1117
 
1140
1118
  it "clears out the relation" do
1141
- person.addresses.should be_empty
1119
+ expect(person.addresses).to be_empty
1142
1120
  end
1143
1121
  end
1144
1122
  end
@@ -1158,7 +1136,7 @@ describe Mongoid::Relations::Embedded::Many do
1158
1136
  end
1159
1137
 
1160
1138
  it "clears out the relation" do
1161
- person.addresses.should be_empty
1139
+ expect(person.addresses).to be_empty
1162
1140
  end
1163
1141
  end
1164
1142
  end
@@ -1180,35 +1158,35 @@ describe Mongoid::Relations::Embedded::Many do
1180
1158
  end
1181
1159
 
1182
1160
  it "appends to the target" do
1183
- person.addresses.should eq([ address ])
1161
+ expect(person.addresses).to eq([ address ])
1184
1162
  end
1185
1163
 
1186
1164
  it "appends to the unscoped" do
1187
- person.addresses.send(:_unscoped).should eq([ address ])
1165
+ expect(person.addresses.send(:_unscoped)).to eq([ address ])
1188
1166
  end
1189
1167
 
1190
1168
  it "sets the base on the inverse relation" do
1191
- address.addressable.should eq(person)
1169
+ expect(address.addressable).to eq(person)
1192
1170
  end
1193
1171
 
1194
1172
  it "sets the same instance on the inverse relation" do
1195
- address.addressable.should eql(person)
1173
+ expect(address.addressable).to eql(person)
1196
1174
  end
1197
1175
 
1198
1176
  it "does not save the new document" do
1199
- address.should_not be_persisted
1177
+ expect(address).to_not be_persisted
1200
1178
  end
1201
1179
 
1202
1180
  it "sets the parent on the child" do
1203
- address._parent.should eq(person)
1181
+ expect(address._parent).to eq(person)
1204
1182
  end
1205
1183
 
1206
1184
  it "sets the metadata on the child" do
1207
- address.metadata.should_not be_nil
1185
+ expect(address.metadata).to_not be_nil
1208
1186
  end
1209
1187
 
1210
1188
  it "sets the index on the child" do
1211
- address._index.should eq(0)
1189
+ expect(address._index).to eq(0)
1212
1190
  end
1213
1191
  end
1214
1192
 
@@ -1227,7 +1205,7 @@ describe Mongoid::Relations::Embedded::Many do
1227
1205
  end
1228
1206
 
1229
1207
  it "saves the new document" do
1230
- address.should be_persisted
1208
+ expect(address).to be_persisted
1231
1209
  end
1232
1210
  end
1233
1211
 
@@ -1243,7 +1221,7 @@ describe Mongoid::Relations::Embedded::Many do
1243
1221
  end
1244
1222
 
1245
1223
  it "doesn't update the target" do
1246
- person.addresses.should be_empty
1224
+ expect(person.addresses).to be_empty
1247
1225
  end
1248
1226
  end
1249
1227
 
@@ -1266,11 +1244,11 @@ describe Mongoid::Relations::Embedded::Many do
1266
1244
  end
1267
1245
 
1268
1246
  it "saves the first document" do
1269
- address_one.should be_persisted
1247
+ expect(address_one).to be_persisted
1270
1248
  end
1271
1249
 
1272
1250
  it "saves the second document" do
1273
- address_two.should be_persisted
1251
+ expect(address_two).to be_persisted
1274
1252
  end
1275
1253
  end
1276
1254
 
@@ -1291,31 +1269,31 @@ describe Mongoid::Relations::Embedded::Many do
1291
1269
  end
1292
1270
 
1293
1271
  it "appends to the target" do
1294
- parent_role.child_roles.should eq([ child_role ])
1272
+ expect(parent_role.child_roles).to eq([ child_role ])
1295
1273
  end
1296
1274
 
1297
1275
  it "sets the base on the inverse relation" do
1298
- child_role.parent_role.should eq(parent_role)
1276
+ expect(child_role.parent_role).to eq(parent_role)
1299
1277
  end
1300
1278
 
1301
1279
  it "sets the same instance on the inverse relation" do
1302
- child_role.parent_role.should eql(parent_role)
1280
+ expect(child_role.parent_role).to eql(parent_role)
1303
1281
  end
1304
1282
 
1305
1283
  it "does not save the new document" do
1306
- child_role.should_not be_persisted
1284
+ expect(child_role).to_not be_persisted
1307
1285
  end
1308
1286
 
1309
1287
  it "sets the parent on the child" do
1310
- child_role._parent.should eq(parent_role)
1288
+ expect(child_role._parent).to eq(parent_role)
1311
1289
  end
1312
1290
 
1313
1291
  it "sets the metadata on the child" do
1314
- child_role.metadata.should_not be_nil
1292
+ expect(child_role.metadata).to_not be_nil
1315
1293
  end
1316
1294
 
1317
1295
  it "sets the index on the child" do
1318
- child_role._index.should eq(0)
1296
+ expect(child_role._index).to eq(0)
1319
1297
  end
1320
1298
  end
1321
1299
 
@@ -1334,7 +1312,7 @@ describe Mongoid::Relations::Embedded::Many do
1334
1312
  end
1335
1313
 
1336
1314
  it "saves the new document" do
1337
- child_role.should be_persisted
1315
+ expect(child_role).to be_persisted
1338
1316
  end
1339
1317
  end
1340
1318
  end
@@ -1352,30 +1330,36 @@ describe Mongoid::Relations::Embedded::Many do
1352
1330
  end
1353
1331
 
1354
1332
  it "returns the number of persisted documents" do
1355
- person.addresses.count.should eq(1)
1333
+ expect(person.addresses.count).to eq(1)
1356
1334
  end
1357
1335
  end
1358
1336
 
1359
1337
  describe "#create" do
1360
1338
 
1361
- context "when providing scoped mass assignment" do
1339
+ context "when providing multiple attributes" do
1362
1340
 
1363
1341
  let(:person) do
1364
1342
  Person.create
1365
1343
  end
1366
1344
 
1367
- let(:video) do
1368
- person.videos.create(
1369
- { title: "Inception", year: 1999 }, as: :admin
1370
- )
1345
+ let!(:addresses) do
1346
+ person.addresses.create([{ street: "Bond" }, { street: "Upper" }])
1347
+ end
1348
+
1349
+ it "creates multiple documents" do
1350
+ expect(addresses.size).to eq(2)
1351
+ end
1352
+
1353
+ it "sets the first attributes" do
1354
+ expect(addresses.first.street).to eq("Bond")
1371
1355
  end
1372
1356
 
1373
- it "sets the attributes for the provided role" do
1374
- video.title.should eq("Inception")
1357
+ it "sets the second attributes" do
1358
+ expect(addresses.last.street).to eq("Upper")
1375
1359
  end
1376
1360
 
1377
- it "does not set the attributes for other roles" do
1378
- video.year.should be_nil
1361
+ it "persists the children" do
1362
+ expect(person.addresses.count).to eq(2)
1379
1363
  end
1380
1364
  end
1381
1365
 
@@ -1392,39 +1376,39 @@ describe Mongoid::Relations::Embedded::Many do
1392
1376
  end
1393
1377
 
1394
1378
  it "appends to the target" do
1395
- person.reload.addresses.should eq([ address ])
1379
+ expect(person.reload.addresses).to eq([ address ])
1396
1380
  end
1397
1381
 
1398
1382
  it "appends to the unscoped" do
1399
- person.reload.addresses.send(:_unscoped).should eq([ address ])
1383
+ expect(person.reload.addresses.send(:_unscoped)).to eq([ address ])
1400
1384
  end
1401
1385
 
1402
1386
  it "sets the base on the inverse relation" do
1403
- address.addressable.should eq(person)
1387
+ expect(address.addressable).to eq(person)
1404
1388
  end
1405
1389
 
1406
1390
  it "saves the document" do
1407
- address.should be_persisted
1391
+ expect(address).to be_persisted
1408
1392
  end
1409
1393
 
1410
1394
  it "sets the parent on the child" do
1411
- address._parent.should eq(person)
1395
+ expect(address._parent).to eq(person)
1412
1396
  end
1413
1397
 
1414
1398
  it "sets the metadata on the child" do
1415
- address.metadata.should_not be_nil
1399
+ expect(address.metadata).to_not be_nil
1416
1400
  end
1417
1401
 
1418
1402
  it "sets the index on the child" do
1419
- address._index.should eq(0)
1403
+ expect(address._index).to eq(0)
1420
1404
  end
1421
1405
 
1422
1406
  it "writes to the attributes" do
1423
- address.street.should eq("Bond")
1407
+ expect(address.street).to eq("Bond")
1424
1408
  end
1425
1409
 
1426
1410
  it "calls the passed block" do
1427
- address.state.should eq("CA")
1411
+ expect(address.state).to eq("CA")
1428
1412
  end
1429
1413
 
1430
1414
  context "when embedding a multi word named document" do
@@ -1434,7 +1418,7 @@ describe Mongoid::Relations::Embedded::Many do
1434
1418
  end
1435
1419
 
1436
1420
  it "saves the embedded document" do
1437
- person.reload.address_components.first.should eq(component)
1421
+ expect(person.reload.address_components.first).to eq(component)
1438
1422
  end
1439
1423
  end
1440
1424
  end
@@ -1450,7 +1434,7 @@ describe Mongoid::Relations::Embedded::Many do
1450
1434
  end
1451
1435
 
1452
1436
  it "creates a new child" do
1453
- child_entry.should be_persisted
1437
+ expect(child_entry).to be_persisted
1454
1438
  end
1455
1439
  end
1456
1440
  end
@@ -1461,20 +1445,26 @@ describe Mongoid::Relations::Embedded::Many do
1461
1445
  Person.create
1462
1446
  end
1463
1447
 
1464
- context "when providing scoped mass assignment" do
1448
+ context "when providing multiple attributes" do
1465
1449
 
1466
- let(:video) do
1467
- person.videos.create!(
1468
- { title: "Inception", year: 1999 }, as: :admin
1469
- )
1450
+ let!(:addresses) do
1451
+ person.addresses.create!([{ street: "Bond" }, { street: "Upper" }])
1452
+ end
1453
+
1454
+ it "creates multiple documents" do
1455
+ expect(addresses.size).to eq(2)
1456
+ end
1457
+
1458
+ it "sets the first attributes" do
1459
+ expect(addresses.first.street).to eq("Bond")
1470
1460
  end
1471
1461
 
1472
- it "sets the attributes for the provided role" do
1473
- video.title.should eq("Inception")
1462
+ it "sets the second attributes" do
1463
+ expect(addresses.last.street).to eq("Upper")
1474
1464
  end
1475
1465
 
1476
- it "does not set the attributes for other roles" do
1477
- video.year.should be_nil
1466
+ it "persists the children" do
1467
+ expect(person.addresses.count).to eq(2)
1478
1468
  end
1479
1469
  end
1480
1470
 
@@ -1485,35 +1475,35 @@ describe Mongoid::Relations::Embedded::Many do
1485
1475
  end
1486
1476
 
1487
1477
  it "appends to the target" do
1488
- person.addresses.should eq([ address ])
1478
+ expect(person.addresses).to eq([ address ])
1489
1479
  end
1490
1480
 
1491
1481
  it "appends to the unscoped" do
1492
- person.addresses.send(:_unscoped).should eq([ address ])
1482
+ expect(person.addresses.send(:_unscoped)).to eq([ address ])
1493
1483
  end
1494
1484
 
1495
1485
  it "sets the base on the inverse relation" do
1496
- address.addressable.should eq(person)
1486
+ expect(address.addressable).to eq(person)
1497
1487
  end
1498
1488
 
1499
1489
  it "saves the document" do
1500
- address.should be_persisted
1490
+ expect(address).to be_persisted
1501
1491
  end
1502
1492
 
1503
1493
  it "sets the parent on the child" do
1504
- address._parent.should eq(person)
1494
+ expect(address._parent).to eq(person)
1505
1495
  end
1506
1496
 
1507
1497
  it "sets the metadata on the child" do
1508
- address.metadata.should_not be_nil
1498
+ expect(address.metadata).to_not be_nil
1509
1499
  end
1510
1500
 
1511
1501
  it "sets the index on the child" do
1512
- address._index.should eq(0)
1502
+ expect(address._index).to eq(0)
1513
1503
  end
1514
1504
 
1515
1505
  it "writes to the attributes" do
1516
- address.street.should eq("Bond")
1506
+ expect(address.street).to eq("Bond")
1517
1507
  end
1518
1508
  end
1519
1509
 
@@ -1552,26 +1542,26 @@ describe Mongoid::Relations::Embedded::Many do
1552
1542
  end
1553
1543
 
1554
1544
  it "deletes the document" do
1555
- person.addresses.should eq([ address_two ])
1545
+ expect(person.addresses).to eq([ address_two ])
1556
1546
  end
1557
1547
 
1558
1548
  it "deletes the document from the unscoped" do
1559
- person.addresses.send(:_unscoped).should eq([ address_two ])
1549
+ expect(person.addresses.send(:_unscoped)).to eq([ address_two ])
1560
1550
  end
1561
1551
 
1562
1552
  it "reindexes the relation" do
1563
- address_two._index.should eq(0)
1553
+ expect(address_two._index).to eq(0)
1564
1554
  end
1565
1555
 
1566
1556
  it "returns the document" do
1567
- deleted.should eq(address_one)
1557
+ expect(deleted).to eq(address_one)
1568
1558
  end
1569
1559
  end
1570
1560
 
1571
1561
  context "when the document does not exist" do
1572
1562
 
1573
1563
  it "returns nil" do
1574
- person.addresses.delete(Address.new).should be_nil
1564
+ expect(person.addresses.delete(Address.new)).to be_nil
1575
1565
  end
1576
1566
  end
1577
1567
  end
@@ -1601,15 +1591,15 @@ describe Mongoid::Relations::Embedded::Many do
1601
1591
  end
1602
1592
 
1603
1593
  it "removes the matching documents" do
1604
- person.addresses.size.should eq(1)
1594
+ expect(person.addresses.size).to eq(1)
1605
1595
  end
1606
1596
 
1607
1597
  it "removes from the unscoped" do
1608
- person.addresses.send(:_unscoped).size.should eq(1)
1598
+ expect(person.addresses.send(:_unscoped).size).to eq(1)
1609
1599
  end
1610
1600
 
1611
1601
  it "returns the relation" do
1612
- deleted.should eq(person.addresses)
1602
+ expect(deleted).to eq(person.addresses)
1613
1603
  end
1614
1604
  end
1615
1605
 
@@ -1620,7 +1610,7 @@ describe Mongoid::Relations::Embedded::Many do
1620
1610
  end
1621
1611
 
1622
1612
  it "returns an enumerator" do
1623
- deleted.should be_a(Enumerator)
1613
+ expect(deleted).to be_a(Enumerator)
1624
1614
  end
1625
1615
  end
1626
1616
  end
@@ -1644,15 +1634,15 @@ describe Mongoid::Relations::Embedded::Many do
1644
1634
  end
1645
1635
 
1646
1636
  it "deletes the matching documents" do
1647
- person.addresses.count.should eq(1)
1637
+ expect(person.addresses.count).to eq(1)
1648
1638
  end
1649
1639
 
1650
1640
  it "deletes the matching documents from the db" do
1651
- person.reload.addresses.count.should eq(1)
1641
+ expect(person.reload.addresses.count).to eq(1)
1652
1642
  end
1653
1643
 
1654
1644
  it "returns the relation" do
1655
- deleted.should eq(person.addresses)
1645
+ expect(deleted).to eq(person.addresses)
1656
1646
  end
1657
1647
  end
1658
1648
  end
@@ -1668,15 +1658,15 @@ describe Mongoid::Relations::Embedded::Many do
1668
1658
  end
1669
1659
 
1670
1660
  it "deletes the matching documents" do
1671
- person.addresses.count.should eq(0)
1661
+ expect(person.addresses.count).to eq(0)
1672
1662
  end
1673
1663
 
1674
1664
  it "deletes all the documents from the db" do
1675
- person.reload.addresses.count.should eq(0)
1665
+ expect(person.reload.addresses.count).to eq(0)
1676
1666
  end
1677
1667
 
1678
1668
  it "returns the relation" do
1679
- deleted.should eq(person.addresses)
1669
+ expect(deleted).to eq(person.addresses)
1680
1670
  end
1681
1671
  end
1682
1672
  end
@@ -1710,15 +1700,15 @@ describe Mongoid::Relations::Embedded::Many do
1710
1700
  end
1711
1701
 
1712
1702
  it "removes the matching documents" do
1713
- person.addresses.size.should eq(1)
1703
+ expect(person.addresses.size).to eq(1)
1714
1704
  end
1715
1705
 
1716
1706
  it "removes from the unscoped" do
1717
- person.addresses.send(:_unscoped).size.should eq(1)
1707
+ expect(person.addresses.send(:_unscoped).size).to eq(1)
1718
1708
  end
1719
1709
 
1720
1710
  it "returns the number deleted" do
1721
- deleted.should eq(1)
1711
+ expect(deleted).to eq(1)
1722
1712
  end
1723
1713
  end
1724
1714
 
@@ -1729,11 +1719,11 @@ describe Mongoid::Relations::Embedded::Many do
1729
1719
  end
1730
1720
 
1731
1721
  it "removes all documents" do
1732
- person.addresses.size.should eq(0)
1722
+ expect(person.addresses.size).to eq(0)
1733
1723
  end
1734
1724
 
1735
1725
  it "returns the number deleted" do
1736
- deleted.should eq(2)
1726
+ expect(deleted).to eq(2)
1737
1727
  end
1738
1728
  end
1739
1729
  end
@@ -1758,15 +1748,15 @@ describe Mongoid::Relations::Embedded::Many do
1758
1748
  end
1759
1749
 
1760
1750
  it "deletes the matching documents" do
1761
- person.addresses.count.should eq(1)
1751
+ expect(person.addresses.count).to eq(1)
1762
1752
  end
1763
1753
 
1764
1754
  it "deletes the matching documents from the db" do
1765
- person.reload.addresses.count.should eq(1)
1755
+ expect(person.reload.addresses.count).to eq(1)
1766
1756
  end
1767
1757
 
1768
1758
  it "returns the number deleted" do
1769
- deleted.should eq(1)
1759
+ expect(deleted).to eq(1)
1770
1760
  end
1771
1761
  end
1772
1762
 
@@ -1777,15 +1767,15 @@ describe Mongoid::Relations::Embedded::Many do
1777
1767
  end
1778
1768
 
1779
1769
  it "deletes all the documents" do
1780
- person.addresses.count.should eq(0)
1770
+ expect(person.addresses.count).to eq(0)
1781
1771
  end
1782
1772
 
1783
1773
  it "deletes all the documents from the db" do
1784
- person.reload.addresses.count.should eq(0)
1774
+ expect(person.reload.addresses.count).to eq(0)
1785
1775
  end
1786
1776
 
1787
1777
  it "returns the number deleted" do
1788
- deleted.should eq(2)
1778
+ expect(deleted).to eq(2)
1789
1779
  end
1790
1780
  end
1791
1781
 
@@ -1803,13 +1793,13 @@ describe Mongoid::Relations::Embedded::Many do
1803
1793
  end
1804
1794
 
1805
1795
  it "removes the documents" do
1806
- owner.pet.vet_visits.should be_empty
1796
+ expect(owner.pet.vet_visits).to be_empty
1807
1797
  end
1808
1798
 
1809
1799
  it "allows addition and a resave" do
1810
1800
  owner.pet.vet_visits << VetVisit.new(date: Date.today)
1811
1801
  owner.save!
1812
- owner.pet.vet_visits.first.should be_persisted
1802
+ expect(owner.pet.vet_visits.first).to be_persisted
1813
1803
  end
1814
1804
  end
1815
1805
  end
@@ -1822,15 +1812,15 @@ describe Mongoid::Relations::Embedded::Many do
1822
1812
  end
1823
1813
 
1824
1814
  it "deletes all the documents" do
1825
- person.addresses.count.should eq(0)
1815
+ expect(person.addresses.count).to eq(0)
1826
1816
  end
1827
1817
 
1828
1818
  it "deletes all the documents from the db" do
1829
- person.reload.addresses.count.should eq(0)
1819
+ expect(person.reload.addresses.count).to eq(0)
1830
1820
  end
1831
1821
 
1832
1822
  it "returns the number deleted" do
1833
- deleted.should eq(0)
1823
+ expect(deleted).to eq(0)
1834
1824
  end
1835
1825
  end
1836
1826
 
@@ -1844,15 +1834,15 @@ describe Mongoid::Relations::Embedded::Many do
1844
1834
  end
1845
1835
 
1846
1836
  it "deletes all the documents" do
1847
- person.addresses.count.should eq(0)
1837
+ expect(person.addresses.count).to eq(0)
1848
1838
  end
1849
1839
 
1850
1840
  it "deletes all the documents from the db" do
1851
- person.reload.addresses.count.should eq(0)
1841
+ expect(person.reload.addresses.count).to eq(0)
1852
1842
  end
1853
1843
 
1854
1844
  it "returns the number deleted" do
1855
- deleted.should eq(0)
1845
+ expect(deleted).to eq(0)
1856
1846
  end
1857
1847
  end
1858
1848
 
@@ -1863,15 +1853,15 @@ describe Mongoid::Relations::Embedded::Many do
1863
1853
  end
1864
1854
 
1865
1855
  it "deletes all the documents" do
1866
- person.addresses.count.should eq(0)
1856
+ expect(person.addresses.count).to eq(0)
1867
1857
  end
1868
1858
 
1869
1859
  it "deletes all the documents from the db" do
1870
- person.reload.addresses.count.should eq(0)
1860
+ expect(person.reload.addresses.count).to eq(0)
1871
1861
  end
1872
1862
 
1873
1863
  it "returns the number deleted" do
1874
- deleted.should eq(0)
1864
+ expect(deleted).to eq(0)
1875
1865
  end
1876
1866
  end
1877
1867
  end
@@ -1881,14 +1871,14 @@ describe Mongoid::Relations::Embedded::Many do
1881
1871
  describe ".embedded?" do
1882
1872
 
1883
1873
  it "returns true" do
1884
- described_class.should be_embedded
1874
+ expect(described_class).to be_embedded
1885
1875
  end
1886
1876
  end
1887
1877
 
1888
1878
  describe ".foreign_key_suffix" do
1889
1879
 
1890
1880
  it "returns nil" do
1891
- described_class.foreign_key_suffix.should be_nil
1881
+ expect(described_class.foreign_key_suffix).to be_nil
1892
1882
  end
1893
1883
  end
1894
1884
 
@@ -1905,7 +1895,7 @@ describe Mongoid::Relations::Embedded::Many do
1905
1895
  end
1906
1896
 
1907
1897
  it "returns true" do
1908
- person.addresses.exists?.should be_true
1898
+ expect(person.addresses.exists?).to be true
1909
1899
  end
1910
1900
  end
1911
1901
 
@@ -1916,7 +1906,7 @@ describe Mongoid::Relations::Embedded::Many do
1916
1906
  end
1917
1907
 
1918
1908
  it "returns false" do
1919
- person.addresses.exists?.should be_false
1909
+ expect(person.addresses.exists?).to be false
1920
1910
  end
1921
1911
  end
1922
1912
  end
@@ -1944,7 +1934,7 @@ describe Mongoid::Relations::Embedded::Many do
1944
1934
  end
1945
1935
 
1946
1936
  it "returns the matching document" do
1947
- address.should eq(address_one)
1937
+ expect(address).to eq(address_one)
1948
1938
  end
1949
1939
  end
1950
1940
 
@@ -1958,7 +1948,7 @@ describe Mongoid::Relations::Embedded::Many do
1958
1948
 
1959
1949
  it "raises an error" do
1960
1950
  expect {
1961
- person.addresses.find(Moped::BSON::ObjectId.new)
1951
+ person.addresses.find(BSON::ObjectId.new)
1962
1952
  }.to raise_error(Mongoid::Errors::DocumentNotFound)
1963
1953
  end
1964
1954
  end
@@ -1966,7 +1956,7 @@ describe Mongoid::Relations::Embedded::Many do
1966
1956
  context "when config set not to raise error" do
1967
1957
 
1968
1958
  let(:address) do
1969
- person.addresses.find(Moped::BSON::ObjectId.new)
1959
+ person.addresses.find(BSON::ObjectId.new)
1970
1960
  end
1971
1961
 
1972
1962
  before do
@@ -1978,7 +1968,7 @@ describe Mongoid::Relations::Embedded::Many do
1978
1968
  end
1979
1969
 
1980
1970
  it "returns nil" do
1981
- address.should be_nil
1971
+ expect(address).to be_nil
1982
1972
  end
1983
1973
  end
1984
1974
  end
@@ -1993,7 +1983,7 @@ describe Mongoid::Relations::Embedded::Many do
1993
1983
  end
1994
1984
 
1995
1985
  it "returns the matching documents" do
1996
- addresses.should eq([ address_one, address_two ])
1986
+ expect(addresses).to eq([ address_one, address_two ])
1997
1987
  end
1998
1988
  end
1999
1989
 
@@ -2007,7 +1997,7 @@ describe Mongoid::Relations::Embedded::Many do
2007
1997
 
2008
1998
  it "raises an error" do
2009
1999
  expect {
2010
- person.addresses.find([ Moped::BSON::ObjectId.new ])
2000
+ person.addresses.find([ BSON::ObjectId.new ])
2011
2001
  }.to raise_error(Mongoid::Errors::DocumentNotFound)
2012
2002
  end
2013
2003
  end
@@ -2015,7 +2005,7 @@ describe Mongoid::Relations::Embedded::Many do
2015
2005
  context "when config set not to raise error" do
2016
2006
 
2017
2007
  let(:addresses) do
2018
- person.addresses.find([ Moped::BSON::ObjectId.new ])
2008
+ person.addresses.find([ BSON::ObjectId.new ])
2019
2009
  end
2020
2010
 
2021
2011
  before do
@@ -2027,7 +2017,7 @@ describe Mongoid::Relations::Embedded::Many do
2027
2017
  end
2028
2018
 
2029
2019
  it "returns an empty array" do
2030
- addresses.should be_empty
2020
+ expect(addresses).to be_empty
2031
2021
  end
2032
2022
  end
2033
2023
  end
@@ -2051,7 +2041,7 @@ describe Mongoid::Relations::Embedded::Many do
2051
2041
  end
2052
2042
 
2053
2043
  it "returns the document" do
2054
- found.should eq(address)
2044
+ expect(found).to eq(address)
2055
2045
  end
2056
2046
  end
2057
2047
 
@@ -2064,15 +2054,15 @@ describe Mongoid::Relations::Embedded::Many do
2064
2054
  end
2065
2055
 
2066
2056
  it "sets the new document attributes" do
2067
- found.street.should eq("King")
2057
+ expect(found.street).to eq("King")
2068
2058
  end
2069
2059
 
2070
2060
  it "returns a newly persisted document" do
2071
- found.should be_persisted
2061
+ expect(found).to be_persisted
2072
2062
  end
2073
2063
 
2074
2064
  it "calls the passed block" do
2075
- found.state.should eq("CA")
2065
+ expect(found.state).to eq("CA")
2076
2066
  end
2077
2067
  end
2078
2068
 
@@ -2094,7 +2084,7 @@ describe Mongoid::Relations::Embedded::Many do
2094
2084
  end
2095
2085
 
2096
2086
  it "properly creates the document" do
2097
- line_item.product.should eq(product)
2087
+ expect(line_item.product).to eq(product)
2098
2088
  end
2099
2089
  end
2100
2090
  end
@@ -2116,7 +2106,7 @@ describe Mongoid::Relations::Embedded::Many do
2116
2106
  end
2117
2107
 
2118
2108
  it "returns the document" do
2119
- found.should eq(address)
2109
+ expect(found).to eq(address)
2120
2110
  end
2121
2111
  end
2122
2112
 
@@ -2129,15 +2119,15 @@ describe Mongoid::Relations::Embedded::Many do
2129
2119
  end
2130
2120
 
2131
2121
  it "sets the new document attributes" do
2132
- found.street.should eq("King")
2122
+ expect(found.street).to eq("King")
2133
2123
  end
2134
2124
 
2135
2125
  it "returns a non persisted document" do
2136
- found.should_not be_persisted
2126
+ expect(found).to_not be_persisted
2137
2127
  end
2138
2128
 
2139
2129
  it "calls the passed block" do
2140
- found.state.should eq("CA")
2130
+ expect(found.state).to eq("CA")
2141
2131
  end
2142
2132
  end
2143
2133
  end
@@ -2145,7 +2135,7 @@ describe Mongoid::Relations::Embedded::Many do
2145
2135
  describe ".macro" do
2146
2136
 
2147
2137
  it "returns embeds_many" do
2148
- described_class.macro.should eq(:embeds_many)
2138
+ expect(described_class.macro).to eq(:embeds_many)
2149
2139
  end
2150
2140
  end
2151
2141
 
@@ -2174,7 +2164,7 @@ describe Mongoid::Relations::Embedded::Many do
2174
2164
  end
2175
2165
 
2176
2166
  it "returns the document with the max value of the supplied field" do
2177
- max.should eq(address_two)
2167
+ expect(max).to eq(address_two)
2178
2168
  end
2179
2169
  end
2180
2170
 
@@ -2201,7 +2191,7 @@ describe Mongoid::Relations::Embedded::Many do
2201
2191
  end
2202
2192
 
2203
2193
  it "returns the document with the max value of the supplied field" do
2204
- max.should eq(address_two)
2194
+ expect(max).to eq(address_two)
2205
2195
  end
2206
2196
  end
2207
2197
 
@@ -2236,7 +2226,7 @@ describe Mongoid::Relations::Embedded::Many do
2236
2226
  end
2237
2227
 
2238
2228
  it "applies the criteria to the documents" do
2239
- addresses.should eq([ address_one ])
2229
+ expect(addresses).to eq([ address_one ])
2240
2230
  end
2241
2231
  end
2242
2232
 
@@ -2247,7 +2237,7 @@ describe Mongoid::Relations::Embedded::Many do
2247
2237
  end
2248
2238
 
2249
2239
  it "applies the criteria to the documents" do
2250
- addresses.should eq([ address_one, address_two ])
2240
+ expect(addresses).to eq([ address_one, address_two ])
2251
2241
  end
2252
2242
  end
2253
2243
 
@@ -2258,7 +2248,7 @@ describe Mongoid::Relations::Embedded::Many do
2258
2248
  end
2259
2249
 
2260
2250
  it "applies the criteria to the documents" do
2261
- addresses.should eq([ address_one, address_two ])
2251
+ expect(addresses).to eq([ address_one, address_two ])
2262
2252
  end
2263
2253
  end
2264
2254
  end
@@ -2270,7 +2260,7 @@ describe Mongoid::Relations::Embedded::Many do
2270
2260
  end
2271
2261
 
2272
2262
  it "applies the criteria to the documents" do
2273
- addresses.should eq([ address_one ])
2263
+ expect(addresses).to eq([ address_one ])
2274
2264
  end
2275
2265
  end
2276
2266
 
@@ -2281,7 +2271,7 @@ describe Mongoid::Relations::Embedded::Many do
2281
2271
  end
2282
2272
 
2283
2273
  it "applies the criteria to the documents" do
2284
- addresses.should eq([ address_one ])
2274
+ expect(addresses).to eq([ address_one ])
2285
2275
  end
2286
2276
  end
2287
2277
 
@@ -2290,8 +2280,7 @@ describe Mongoid::Relations::Embedded::Many do
2290
2280
  describe "#distinct" do
2291
2281
 
2292
2282
  it "returns the distinct values for the fields" do
2293
- person.addresses.distinct(:street).should =~
2294
- [ "Market", "Madison"]
2283
+ expect(person.addresses.distinct(:street)).to eq([ "Market", "Madison"])
2295
2284
  end
2296
2285
  end
2297
2286
  end
@@ -2322,7 +2311,7 @@ describe Mongoid::Relations::Embedded::Many do
2322
2311
  end
2323
2312
 
2324
2313
  it "returns the min value of the supplied field" do
2325
- min.should eq(address_one)
2314
+ expect(min).to eq(address_one)
2326
2315
  end
2327
2316
  end
2328
2317
 
@@ -2349,7 +2338,7 @@ describe Mongoid::Relations::Embedded::Many do
2349
2338
  end
2350
2339
 
2351
2340
  it "returns the min value of the supplied field" do
2352
- min.should eq(address_one)
2341
+ expect(min).to eq(address_one)
2353
2342
  end
2354
2343
  end
2355
2344
 
@@ -2360,8 +2349,9 @@ describe Mongoid::Relations::Embedded::Many do
2360
2349
  end
2361
2350
 
2362
2351
  it "returns the many nested builder class" do
2363
- described_class.nested_builder(metadata, {}, {}).should
2364
- be_a(Mongoid::Relations::Builders::NestedAttributes::Many)
2352
+ expect(
2353
+ described_class.nested_builder(metadata, {}, {})
2354
+ ).to be_a(Mongoid::Relations::Builders::NestedAttributes::Many)
2365
2355
  end
2366
2356
  end
2367
2357
 
@@ -2386,15 +2376,15 @@ describe Mongoid::Relations::Embedded::Many do
2386
2376
  end
2387
2377
 
2388
2378
  it "returns the popped document" do
2389
- popped.should eq(address_two)
2379
+ expect(popped).to eq(address_two)
2390
2380
  end
2391
2381
 
2392
2382
  it "removes the document from the relation" do
2393
- person.addresses.should eq([ address_one ])
2383
+ expect(person.addresses).to eq([ address_one ])
2394
2384
  end
2395
2385
 
2396
2386
  it "persists the pop" do
2397
- person.reload.addresses.should eq([ address_one ])
2387
+ expect(person.reload.addresses).to eq([ address_one ])
2398
2388
  end
2399
2389
  end
2400
2390
 
@@ -2415,15 +2405,15 @@ describe Mongoid::Relations::Embedded::Many do
2415
2405
  end
2416
2406
 
2417
2407
  it "returns the popped documents" do
2418
- popped.should eq([ address_one, address_two ])
2408
+ expect(popped).to eq([ address_one, address_two ])
2419
2409
  end
2420
2410
 
2421
2411
  it "removes the document from the relation" do
2422
- person.addresses.should be_empty
2412
+ expect(person.addresses).to be_empty
2423
2413
  end
2424
2414
 
2425
2415
  it "persists the pop" do
2426
- person.reload.addresses.should be_empty
2416
+ expect(person.reload.addresses).to be_empty
2427
2417
  end
2428
2418
  end
2429
2419
 
@@ -2434,15 +2424,15 @@ describe Mongoid::Relations::Embedded::Many do
2434
2424
  end
2435
2425
 
2436
2426
  it "returns the popped documents" do
2437
- popped.should eq([ address_one, address_two ])
2427
+ expect(popped).to eq([ address_one, address_two ])
2438
2428
  end
2439
2429
 
2440
2430
  it "removes the document from the relation" do
2441
- person.addresses.should be_empty
2431
+ expect(person.addresses).to be_empty
2442
2432
  end
2443
2433
 
2444
2434
  it "persists the pop" do
2445
- person.reload.addresses.should be_empty
2435
+ expect(person.reload.addresses).to be_empty
2446
2436
  end
2447
2437
  end
2448
2438
  end
@@ -2452,14 +2442,14 @@ describe Mongoid::Relations::Embedded::Many do
2452
2442
  context "when providing no number" do
2453
2443
 
2454
2444
  it "returns nil" do
2455
- person.addresses.pop.should be_nil
2445
+ expect(person.addresses.pop).to be_nil
2456
2446
  end
2457
2447
  end
2458
2448
 
2459
2449
  context "when providing a number" do
2460
2450
 
2461
2451
  it "returns nil" do
2462
- person.addresses.pop(2).should be_nil
2452
+ expect(person.addresses.pop(2)).to be_nil
2463
2453
  end
2464
2454
  end
2465
2455
  end
@@ -2476,11 +2466,11 @@ describe Mongoid::Relations::Embedded::Many do
2476
2466
  end
2477
2467
 
2478
2468
  it "returns the relation criteria" do
2479
- scoped.should be_a(Mongoid::Criteria)
2469
+ expect(scoped).to be_a(Mongoid::Criteria)
2480
2470
  end
2481
2471
 
2482
2472
  it "returns with an empty selector" do
2483
- scoped.selector.should be_empty
2473
+ expect(scoped.selector).to be_empty
2484
2474
  end
2485
2475
  end
2486
2476
 
@@ -2499,7 +2489,7 @@ describe Mongoid::Relations::Embedded::Many do
2499
2489
  context "when checking #{method}" do
2500
2490
 
2501
2491
  it "returns true" do
2502
- addresses.respond_to?(method).should be_true
2492
+ expect(addresses.respond_to?(method)).to be true
2503
2493
  end
2504
2494
  end
2505
2495
  end
@@ -2509,7 +2499,7 @@ describe Mongoid::Relations::Embedded::Many do
2509
2499
  context "when checking #{method}" do
2510
2500
 
2511
2501
  it "returns true" do
2512
- addresses.respond_to?(method).should be_true
2502
+ expect(addresses.respond_to?(method)).to be true
2513
2503
  end
2514
2504
  end
2515
2505
  end
@@ -2519,7 +2509,7 @@ describe Mongoid::Relations::Embedded::Many do
2519
2509
  context "when checking #{method}" do
2520
2510
 
2521
2511
  it "returns true" do
2522
- addresses.respond_to?(method).should be_true
2512
+ expect(addresses.respond_to?(method)).to be true
2523
2513
  end
2524
2514
  end
2525
2515
  end
@@ -2543,7 +2533,7 @@ describe Mongoid::Relations::Embedded::Many do
2543
2533
  end
2544
2534
 
2545
2535
  it "returns the number of persisted documents" do
2546
- person.addresses.send(method).should eq(2)
2536
+ expect(person.addresses.send(method)).to eq(2)
2547
2537
  end
2548
2538
  end
2549
2539
  end
@@ -2559,15 +2549,15 @@ describe Mongoid::Relations::Embedded::Many do
2559
2549
  end
2560
2550
 
2561
2551
  it "returns the relation criteria" do
2562
- unscoped.should be_a(Mongoid::Criteria)
2552
+ expect(unscoped).to be_a(Mongoid::Criteria)
2563
2553
  end
2564
2554
 
2565
2555
  it "returns with empty options" do
2566
- unscoped.options.should be_empty
2556
+ expect(unscoped.options).to be_empty
2567
2557
  end
2568
2558
 
2569
2559
  it "returns with an empty selector" do
2570
- unscoped.selector.should be_empty
2560
+ expect(unscoped.selector).to be_empty
2571
2561
  end
2572
2562
  end
2573
2563
 
@@ -2580,7 +2570,7 @@ describe Mongoid::Relations::Embedded::Many do
2580
2570
  end
2581
2571
 
2582
2572
  it "updates nothing" do
2583
- person.addresses.update_all(street: "test").should be_false
2573
+ expect(person.addresses.update_all(street: "test")).to be false
2584
2574
  end
2585
2575
  end
2586
2576
 
@@ -2603,19 +2593,19 @@ describe Mongoid::Relations::Embedded::Many do
2603
2593
  end
2604
2594
 
2605
2595
  it "resets the matching dirty flags" do
2606
- address.should_not be_changed
2596
+ expect(address).to_not be_changed
2607
2597
  end
2608
2598
 
2609
2599
  it "updates the first field" do
2610
- address.reload.number.should eq(26)
2600
+ expect(address.reload.number).to eq(26)
2611
2601
  end
2612
2602
 
2613
2603
  it "updates the second field" do
2614
- address.reload.post_code.should eq("12437")
2604
+ expect(address.reload.post_code).to eq("12437")
2615
2605
  end
2616
2606
 
2617
2607
  it "does not wipe out other fields" do
2618
- address.reload.street.should eq("Hobrecht")
2608
+ expect(address.reload.street).to eq("Hobrecht")
2619
2609
  end
2620
2610
  end
2621
2611
  end
@@ -2624,9 +2614,9 @@ describe Mongoid::Relations::Embedded::Many do
2624
2614
  describe ".valid_options" do
2625
2615
 
2626
2616
  it "returns the valid options" do
2627
- described_class.valid_options.should eq(
2617
+ expect(described_class.valid_options).to eq(
2628
2618
  [
2629
- :as, :cascade_callbacks, :cyclic, :order, :versioned,
2619
+ :as, :cascade_callbacks, :cyclic, :order,
2630
2620
  :store_as, :before_add, :after_add, :before_remove, :after_remove
2631
2621
  ]
2632
2622
  )
@@ -2636,7 +2626,7 @@ describe Mongoid::Relations::Embedded::Many do
2636
2626
  describe ".validation_default" do
2637
2627
 
2638
2628
  it "returns true" do
2639
- described_class.validation_default.should be_true
2629
+ expect(described_class.validation_default).to be true
2640
2630
  end
2641
2631
  end
2642
2632
 
@@ -2663,15 +2653,15 @@ describe Mongoid::Relations::Embedded::Many do
2663
2653
  end
2664
2654
 
2665
2655
  it "updates the attributes" do
2666
- address.locations.first.name.should eq("home")
2656
+ expect(address.locations.first.name).to eq("home")
2667
2657
  end
2668
2658
 
2669
2659
  it "overwrites the existing documents" do
2670
- address.locations.count.should eq(1)
2660
+ expect(address.locations.count).to eq(1)
2671
2661
  end
2672
2662
 
2673
2663
  it "persists the changes" do
2674
- address.reload.locations.count.should eq(1)
2664
+ expect(address.reload.locations.count).to eq(1)
2675
2665
  end
2676
2666
  end
2677
2667
  end
@@ -2701,15 +2691,15 @@ describe Mongoid::Relations::Embedded::Many do
2701
2691
  end
2702
2692
 
2703
2693
  it "sets up the hierarchy" do
2704
- animal.circus.should eq(circus)
2694
+ expect(animal.circus).to eq(circus)
2705
2695
  end
2706
2696
 
2707
2697
  it "assigns the attributes" do
2708
- animal.name.should eq(animal_name)
2698
+ expect(animal.name).to eq(animal_name)
2709
2699
  end
2710
2700
 
2711
2701
  it "uses custom writer methods" do
2712
- animal.tag_list.should eq(tag_list)
2702
+ expect(animal.tag_list).to eq(tag_list)
2713
2703
  end
2714
2704
  end
2715
2705
 
@@ -2720,15 +2710,15 @@ describe Mongoid::Relations::Embedded::Many do
2720
2710
  end
2721
2711
 
2722
2712
  it "sets up the hierarchy" do
2723
- animal.circus.should eq(circus)
2713
+ expect(animal.circus).to eq(circus)
2724
2714
  end
2725
2715
 
2726
2716
  it "assigns the attributes" do
2727
- animal.name.should eq(animal_name)
2717
+ expect(animal.name).to eq(animal_name)
2728
2718
  end
2729
2719
 
2730
2720
  it "uses custom writer methods" do
2731
- animal.tag_list.should eq(tag_list)
2721
+ expect(animal.tag_list).to eq(tag_list)
2732
2722
  end
2733
2723
  end
2734
2724
  end
@@ -2757,7 +2747,7 @@ describe Mongoid::Relations::Embedded::Many do
2757
2747
  end
2758
2748
 
2759
2749
  it "sets up the hierarchy" do
2760
- question.should eq(page_question)
2750
+ expect(question).to eq(page_question)
2761
2751
  end
2762
2752
  end
2763
2753
 
@@ -2780,7 +2770,7 @@ describe Mongoid::Relations::Embedded::Many do
2780
2770
  end
2781
2771
 
2782
2772
  it "sets up the hierarchy" do
2783
- question.should eq(page_question)
2773
+ expect(question).to eq(page_question)
2784
2774
  end
2785
2775
  end
2786
2776
 
@@ -2808,7 +2798,7 @@ describe Mongoid::Relations::Embedded::Many do
2808
2798
  end
2809
2799
 
2810
2800
  it "sets up the hierarchy" do
2811
- question.should eq(page_question)
2801
+ expect(question).to eq(page_question)
2812
2802
  end
2813
2803
 
2814
2804
  context "when reloading" do
@@ -2822,7 +2812,7 @@ describe Mongoid::Relations::Embedded::Many do
2822
2812
  end
2823
2813
 
2824
2814
  it "reloads the entire tree" do
2825
- reloaded_question.should eq(question)
2815
+ expect(reloaded_question).to eq(question)
2826
2816
  end
2827
2817
  end
2828
2818
  end
@@ -2856,11 +2846,11 @@ describe Mongoid::Relations::Embedded::Many do
2856
2846
  end
2857
2847
 
2858
2848
  it "persists the first level document" do
2859
- person.reload.addresses.first.should eq(address)
2849
+ expect(person.reload.addresses.first).to eq(address)
2860
2850
  end
2861
2851
 
2862
2852
  it "persists the second level document" do
2863
- person.reload.addresses[0].locations.should eq([ location ])
2853
+ expect(person.reload.addresses[0].locations).to eq([ location ])
2864
2854
  end
2865
2855
  end
2866
2856
  end
@@ -2895,7 +2885,7 @@ describe Mongoid::Relations::Embedded::Many do
2895
2885
 
2896
2886
  it "ignores the nil and persist the remaining items" do
2897
2887
  reloaded = Person.find(person.id)
2898
- reloaded.phone_numbers.should eq([ home_phone, office_phone ])
2888
+ expect(reloaded.phone_numbers).to eq([ home_phone, office_phone ])
2899
2889
  end
2900
2890
  end
2901
2891
 
@@ -2916,7 +2906,7 @@ describe Mongoid::Relations::Embedded::Many do
2916
2906
 
2917
2907
  it "ignores the nil and persist the remaining items" do
2918
2908
  reloaded = Person.find(person.id)
2919
- reloaded.phone_numbers.should eq([ home_phone, office_phone ])
2909
+ expect(reloaded.phone_numbers).to eq([ home_phone, office_phone ])
2920
2910
  end
2921
2911
  end
2922
2912
 
@@ -2937,7 +2927,7 @@ describe Mongoid::Relations::Embedded::Many do
2937
2927
 
2938
2928
  it "ignores the nil and persist the remaining items" do
2939
2929
  reloaded = Person.find(person.id)
2940
- reloaded.phone_numbers.should eq([ home_phone, office_phone ])
2930
+ expect(reloaded.phone_numbers).to eq([ home_phone, office_phone ])
2941
2931
  end
2942
2932
  end
2943
2933
  end
@@ -2959,7 +2949,7 @@ describe Mongoid::Relations::Embedded::Many do
2959
2949
 
2960
2950
  it "ignores the nil and persist the remaining items" do
2961
2951
  reloaded = Person.find(person.id)
2962
- reloaded.phone_numbers.should eq(person.phone_numbers)
2952
+ expect(reloaded.phone_numbers).to eq(person.phone_numbers)
2963
2953
  end
2964
2954
  end
2965
2955
 
@@ -2978,7 +2968,7 @@ describe Mongoid::Relations::Embedded::Many do
2978
2968
 
2979
2969
  it "ignores the nil and persist the remaining items" do
2980
2970
  reloaded = Person.find(person.id)
2981
- reloaded.phone_numbers.should eq(person.phone_numbers)
2971
+ expect(reloaded.phone_numbers).to eq(person.phone_numbers)
2982
2972
  end
2983
2973
  end
2984
2974
 
@@ -2997,7 +2987,7 @@ describe Mongoid::Relations::Embedded::Many do
2997
2987
 
2998
2988
  it "ignores the nil and persist the remaining items" do
2999
2989
  reloaded = Person.find(person.id)
3000
- reloaded.phone_numbers.should eq(person.phone_numbers)
2990
+ expect(reloaded.phone_numbers).to eq(person.phone_numbers)
3001
2991
  end
3002
2992
  end
3003
2993
  end
@@ -3018,7 +3008,7 @@ describe Mongoid::Relations::Embedded::Many do
3018
3008
  end
3019
3009
 
3020
3010
  it "retains the reference to the parent" do
3021
- league.name.should eq("Destroyed")
3011
+ expect(league.name).to eq("Destroyed")
3022
3012
  end
3023
3013
  end
3024
3014
 
@@ -3037,11 +3027,11 @@ describe Mongoid::Relations::Embedded::Many do
3037
3027
  end
3038
3028
 
3039
3029
  it "does not duplicate the embedded documents" do
3040
- person.addresses.should eq([ address ])
3030
+ expect(person.addresses).to eq([ address ])
3041
3031
  end
3042
3032
 
3043
3033
  it "does not persist duplicate embedded documents" do
3044
- person.reload.addresses.should eq([ address ])
3034
+ expect(person.reload.addresses).to eq([ address ])
3045
3035
  end
3046
3036
  end
3047
3037
 
@@ -3058,7 +3048,7 @@ describe Mongoid::Relations::Embedded::Many do
3058
3048
  end
3059
3049
 
3060
3050
  it "allows the operation" do
3061
- version.number.should eq(1)
3051
+ expect(version.number).to eq(1)
3062
3052
  end
3063
3053
 
3064
3054
  context "when reloading the parent" do
@@ -3068,7 +3058,7 @@ describe Mongoid::Relations::Embedded::Many do
3068
3058
  end
3069
3059
 
3070
3060
  it "saves the child versions" do
3071
- from_db.versions.should eq([ version ])
3061
+ expect(from_db.versions).to eq([ version ])
3072
3062
  end
3073
3063
  end
3074
3064
  end
@@ -3095,7 +3085,7 @@ describe Mongoid::Relations::Embedded::Many do
3095
3085
  end
3096
3086
 
3097
3087
  it "does not lose the parent reference" do
3098
- from_db.memberships.first.account.should eq(account)
3088
+ expect(from_db.memberships.first.account).to eq(account)
3099
3089
  end
3100
3090
  end
3101
3091
 
@@ -3106,7 +3096,7 @@ describe Mongoid::Relations::Embedded::Many do
3106
3096
  end
3107
3097
 
3108
3098
  it "does not lose the parent reference" do
3109
- from_db.memberships.first.account.should eq(account)
3099
+ expect(from_db.memberships.first.account).to eq(account)
3110
3100
  end
3111
3101
  end
3112
3102
  end
@@ -3130,11 +3120,11 @@ describe Mongoid::Relations::Embedded::Many do
3130
3120
  end
3131
3121
 
3132
3122
  it "adds the document to the new paarent" do
3133
- person_two.addresses.should eq([ address ])
3123
+ expect(person_two.addresses).to eq([ address ])
3134
3124
  end
3135
3125
 
3136
3126
  it "sets the new parent on the document" do
3137
- address._parent.should eq(person_two)
3127
+ expect(address._parent).to eq(person_two)
3138
3128
  end
3139
3129
 
3140
3130
  context "when reloading the documents" do
@@ -3145,11 +3135,11 @@ describe Mongoid::Relations::Embedded::Many do
3145
3135
  end
3146
3136
 
3147
3137
  it "persists the change to the new parent" do
3148
- person_two.addresses.should eq([ address ])
3138
+ expect(person_two.addresses).to eq([ address ])
3149
3139
  end
3150
3140
 
3151
3141
  it "keeps the address on the previous document" do
3152
- person_one.addresses.should eq([ address ])
3142
+ expect(person_one.addresses).to eq([ address ])
3153
3143
  end
3154
3144
  end
3155
3145
  end
@@ -3185,7 +3175,7 @@ describe Mongoid::Relations::Embedded::Many do
3185
3175
  end
3186
3176
 
3187
3177
  it "applies the default scope" do
3188
- symptoms.should eq([ cough, headache, nausea ])
3178
+ expect(symptoms).to eq([ cough, headache, nausea ])
3189
3179
  end
3190
3180
  end
3191
3181
 
@@ -3206,7 +3196,7 @@ describe Mongoid::Relations::Embedded::Many do
3206
3196
  end
3207
3197
 
3208
3198
  it "applies the default scope" do
3209
- symptoms.should eq([ constipation, cough, headache, nausea ])
3199
+ expect(symptoms).to eq([ constipation, cough, headache, nausea ])
3210
3200
  end
3211
3201
  end
3212
3202
  end
@@ -3218,7 +3208,7 @@ describe Mongoid::Relations::Embedded::Many do
3218
3208
  end
3219
3209
 
3220
3210
  it "removes the default scope" do
3221
- unscoped.should eq([ nausea, cough, headache ])
3211
+ expect(unscoped).to eq([ nausea, cough, headache ])
3222
3212
  end
3223
3213
  end
3224
3214
  end
@@ -3249,11 +3239,11 @@ describe Mongoid::Relations::Embedded::Many do
3249
3239
  end
3250
3240
 
3251
3241
  it "retains the unscoped index for the excluded document" do
3252
- relation.send(:_unscoped).first._index.should eq(0)
3242
+ expect(relation.send(:_unscoped).first._index).to eq(0)
3253
3243
  end
3254
3244
 
3255
3245
  it "retains the unscoped index for the included document" do
3256
- relation.first._index.should eq(1)
3246
+ expect(relation.first._index).to eq(1)
3257
3247
  end
3258
3248
 
3259
3249
  context "when a reindexing operation occurs" do
@@ -3263,11 +3253,11 @@ describe Mongoid::Relations::Embedded::Many do
3263
3253
  end
3264
3254
 
3265
3255
  it "retains the unscoped index for the excluded document" do
3266
- relation.send(:_unscoped).first._index.should eq(0)
3256
+ expect(relation.send(:_unscoped).first._index).to eq(0)
3267
3257
  end
3268
3258
 
3269
3259
  it "retains the unscoped index for the included document" do
3270
- relation.first._index.should eq(1)
3260
+ expect(relation.first._index).to eq(1)
3271
3261
  end
3272
3262
  end
3273
3263
  end
@@ -3291,11 +3281,11 @@ describe Mongoid::Relations::Embedded::Many do
3291
3281
  end
3292
3282
 
3293
3283
  it "sets the value" do
3294
- video.genres.should eq([ "horror", "scifi" ])
3284
+ expect(video.genres).to eq([ "horror", "scifi" ])
3295
3285
  end
3296
3286
 
3297
3287
  it "persists the value" do
3298
- video.reload.genres.should eq([ "horror", "scifi" ])
3288
+ expect(video.reload.genres).to eq([ "horror", "scifi" ])
3299
3289
  end
3300
3290
 
3301
3291
  context "when reloading the parent" do
@@ -3316,11 +3306,11 @@ describe Mongoid::Relations::Embedded::Many do
3316
3306
  end
3317
3307
 
3318
3308
  it "sets the new value" do
3319
- loaded_video.genres.should eq([ "comedy" ])
3309
+ expect(loaded_video.genres).to eq([ "comedy" ])
3320
3310
  end
3321
3311
 
3322
3312
  it "persists the new value" do
3323
- loaded_video.reload.genres.should eq([ "comedy" ])
3313
+ expect(loaded_video.reload.genres).to eq([ "comedy" ])
3324
3314
  end
3325
3315
  end
3326
3316
  end
@@ -3346,15 +3336,15 @@ describe Mongoid::Relations::Embedded::Many do
3346
3336
  end
3347
3337
 
3348
3338
  it "destroys the document" do
3349
- address_one.should be_destroyed
3339
+ expect(address_one).to be_destroyed
3350
3340
  end
3351
3341
 
3352
3342
  it "reindexes the relation" do
3353
- address_two._index.should eq(0)
3343
+ expect(address_two._index).to eq(0)
3354
3344
  end
3355
3345
 
3356
3346
  it "removes the document from the unscoped" do
3357
- person.addresses.send(:_unscoped).should_not include(address_one)
3347
+ expect(person.addresses.send(:_unscoped)).to_not include(address_one)
3358
3348
  end
3359
3349
 
3360
3350
  context "when subsequently updating the next document" do
@@ -3368,11 +3358,11 @@ describe Mongoid::Relations::Embedded::Many do
3368
3358
  end
3369
3359
 
3370
3360
  it "updates the correct document" do
3371
- addresses.first.number.should eq(10)
3361
+ expect(addresses.first.number).to eq(10)
3372
3362
  end
3373
3363
 
3374
3364
  it "does not add additional documents" do
3375
- addresses.count.should eq(1)
3365
+ expect(addresses.count).to eq(1)
3376
3366
  end
3377
3367
  end
3378
3368
  end
@@ -3402,7 +3392,7 @@ describe Mongoid::Relations::Embedded::Many do
3402
3392
  end
3403
3393
 
3404
3394
  it "adds both documents" do
3405
- result.should eq([ address_one, address_two ])
3395
+ expect(result).to eq([ address_one, address_two ])
3406
3396
  end
3407
3397
  end
3408
3398
  end
@@ -3426,7 +3416,7 @@ describe Mongoid::Relations::Embedded::Many do
3426
3416
  end
3427
3417
 
3428
3418
  it "allows the dot notation criteria" do
3429
- criteria.should eq([ address ])
3419
+ expect(criteria).to eq([ address ])
3430
3420
  end
3431
3421
  end
3432
3422
 
@@ -3459,7 +3449,7 @@ describe Mongoid::Relations::Embedded::Many do
3459
3449
  end
3460
3450
 
3461
3451
  it "updates the nested document" do
3462
- updated.name.should eq("work")
3452
+ expect(updated.name).to eq("work")
3463
3453
  end
3464
3454
  end
3465
3455
  end
@@ -3479,7 +3469,7 @@ describe Mongoid::Relations::Embedded::Many do
3479
3469
  end
3480
3470
 
3481
3471
  it "orders properly with the boolean" do
3482
- circuit.reload.buses.should eq([ bus_two, bus_one ])
3472
+ expect(circuit.reload.buses).to eq([ bus_two, bus_one ])
3483
3473
  end
3484
3474
  end
3485
3475
 
@@ -3517,11 +3507,11 @@ describe Mongoid::Relations::Embedded::Many do
3517
3507
  end
3518
3508
 
3519
3509
  it "does not duplicate the first relation" do
3520
- person.reload.symptoms.count.should eq(2)
3510
+ expect(person.reload.symptoms.count).to eq(2)
3521
3511
  end
3522
3512
 
3523
3513
  it "does not duplicate the second relation" do
3524
- person.reload.appointments.count.should eq(2)
3514
+ expect(person.reload.appointments.count).to eq(2)
3525
3515
  end
3526
3516
  end
3527
3517
 
@@ -3542,15 +3532,15 @@ describe Mongoid::Relations::Embedded::Many do
3542
3532
  end
3543
3533
 
3544
3534
  it "executes the callback" do
3545
- artist.before_add_called.should be_true
3535
+ expect(artist.before_add_called).to be true
3546
3536
  end
3547
3537
 
3548
3538
  it "executes the callback as proc" do
3549
- song.before_add_called.should be_true
3539
+ expect(song.before_add_called).to be true
3550
3540
  end
3551
3541
 
3552
3542
  it "adds the document to the relation" do
3553
- artist.songs.should eq([song])
3543
+ expect(artist.songs).to eq([song])
3554
3544
  end
3555
3545
  end
3556
3546
 
@@ -3564,7 +3554,7 @@ describe Mongoid::Relations::Embedded::Many do
3564
3554
  expect {
3565
3555
  artist.songs << song
3566
3556
  }.to raise_error
3567
- artist.songs.should be_empty
3557
+ expect(artist.songs).to be_empty
3568
3558
  end
3569
3559
  end
3570
3560
  end
@@ -3581,7 +3571,7 @@ describe Mongoid::Relations::Embedded::Many do
3581
3571
 
3582
3572
  it "executes the callback" do
3583
3573
  artist.labels << label
3584
- artist.after_add_called.should be_true
3574
+ expect(artist.after_add_called).to be true
3585
3575
  end
3586
3576
 
3587
3577
  context "when errors are raised" do
@@ -3594,7 +3584,7 @@ describe Mongoid::Relations::Embedded::Many do
3594
3584
  expect {
3595
3585
  artist.labels << label
3596
3586
  }.to raise_error
3597
- artist.labels.should eq([ label ])
3587
+ expect(artist.labels).to eq([ label ])
3598
3588
  end
3599
3589
  end
3600
3590
  end
@@ -3622,11 +3612,11 @@ describe Mongoid::Relations::Embedded::Many do
3622
3612
  end
3623
3613
 
3624
3614
  it "executes the callback" do
3625
- artist.before_remove_embedded_called.should be_true
3615
+ expect(artist.before_remove_embedded_called).to be true
3626
3616
  end
3627
3617
 
3628
3618
  it "removes the document from the relation" do
3629
- artist.songs.should be_empty
3619
+ expect(artist.songs).to be_empty
3630
3620
  end
3631
3621
  end
3632
3622
 
@@ -3637,11 +3627,11 @@ describe Mongoid::Relations::Embedded::Many do
3637
3627
  end
3638
3628
 
3639
3629
  it "executes the callback" do
3640
- artist.before_remove_embedded_called.should be_true
3630
+ expect(artist.before_remove_embedded_called).to be true
3641
3631
  end
3642
3632
 
3643
3633
  it "shoud clear the relation" do
3644
- artist.songs.should be_empty
3634
+ expect(artist.songs).to be_empty
3645
3635
  end
3646
3636
  end
3647
3637
 
@@ -3657,7 +3647,7 @@ describe Mongoid::Relations::Embedded::Many do
3657
3647
  expect {
3658
3648
  artist.songs.delete(song)
3659
3649
  }.to raise_error
3660
- artist.songs.should eq([ song ])
3650
+ expect(artist.songs).to eq([ song ])
3661
3651
  end
3662
3652
  end
3663
3653
 
@@ -3667,7 +3657,7 @@ describe Mongoid::Relations::Embedded::Many do
3667
3657
  expect {
3668
3658
  artist.songs.clear
3669
3659
  }.to raise_error
3670
- artist.songs.should eq([ song ])
3660
+ expect(artist.songs).to eq([ song ])
3671
3661
  end
3672
3662
  end
3673
3663
  end
@@ -3696,7 +3686,7 @@ describe Mongoid::Relations::Embedded::Many do
3696
3686
  end
3697
3687
 
3698
3688
  it "executes the callback" do
3699
- artist.after_remove_embedded_called.should be_true
3689
+ expect(artist.after_remove_embedded_called).to be true
3700
3690
  end
3701
3691
  end
3702
3692
 
@@ -3708,7 +3698,7 @@ describe Mongoid::Relations::Embedded::Many do
3708
3698
 
3709
3699
  it "executes the callback" do
3710
3700
  artist.labels.clear
3711
- artist.after_remove_embedded_called.should be_true
3701
+ expect(artist.after_remove_embedded_called).to be true
3712
3702
  end
3713
3703
  end
3714
3704
  end
@@ -3728,7 +3718,7 @@ describe Mongoid::Relations::Embedded::Many do
3728
3718
  end
3729
3719
 
3730
3720
  it "removes the document from the relation" do
3731
- artist.labels.should be_empty
3721
+ expect(artist.labels).to be_empty
3732
3722
  end
3733
3723
  end
3734
3724
 
@@ -3741,7 +3731,7 @@ describe Mongoid::Relations::Embedded::Many do
3741
3731
  end
3742
3732
 
3743
3733
  it "should remove from collection" do
3744
- artist.labels.should be_empty
3734
+ expect(artist.labels).to be_empty
3745
3735
  end
3746
3736
  end
3747
3737
  end
@@ -3764,7 +3754,7 @@ describe Mongoid::Relations::Embedded::Many do
3764
3754
  end
3765
3755
 
3766
3756
  it "does not push the embedded documents twice" do
3767
- server.reload.filesystems.count.should eq(1)
3757
+ expect(server.reload.filesystems.count).to eq(1)
3768
3758
  end
3769
3759
  end
3770
3760
  end
@@ -3792,11 +3782,11 @@ describe Mongoid::Relations::Embedded::Many do
3792
3782
  end
3793
3783
 
3794
3784
  it "creates proper documents from the db" do
3795
- record.name.should eq("Moderat")
3785
+ expect(record.name).to eq("Moderat")
3796
3786
  end
3797
3787
 
3798
3788
  it "assigns ids to the documents" do
3799
- record.id.should_not be_nil
3789
+ expect(record.id).to_not be_nil
3800
3790
  end
3801
3791
 
3802
3792
  context "when subsequently updating the documents" do
@@ -3806,11 +3796,11 @@ describe Mongoid::Relations::Embedded::Many do
3806
3796
  end
3807
3797
 
3808
3798
  it "updates the document" do
3809
- record.name.should eq("Apparat")
3799
+ expect(record.name).to eq("Apparat")
3810
3800
  end
3811
3801
 
3812
3802
  it "persists the change" do
3813
- record.reload.name.should eq("Apparat")
3803
+ expect(record.reload.name).to eq("Apparat")
3814
3804
  end
3815
3805
  end
3816
3806
  end
@@ -3835,7 +3825,7 @@ describe Mongoid::Relations::Embedded::Many do
3835
3825
  end
3836
3826
 
3837
3827
  it "keeps the proxy extensions when remarshalling" do
3838
- loaded.extension.should eq("Testing")
3828
+ expect(loaded.extension).to eq("Testing")
3839
3829
  end
3840
3830
  end
3841
3831
  end