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
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Mongoid::NestedAttributes do
3
+ describe Mongoid::Attributes::Nested do
4
4
 
5
5
  describe ".accepts_nested_attributes_for" do
6
6
 
@@ -65,7 +65,7 @@ describe Mongoid::NestedAttributes do
65
65
  end
66
66
 
67
67
  it "sets the nested attributes" do
68
- person.name.first_name.should eq("Johnny")
68
+ expect(person.name.first_name).to eq("Johnny")
69
69
  end
70
70
  end
71
71
 
@@ -81,7 +81,7 @@ describe Mongoid::NestedAttributes do
81
81
  end
82
82
 
83
83
  it "sets the nested attributes" do
84
- person.addresses.first.street.should eq("Alexanderstr")
84
+ expect(person.addresses.first.street).to eq("Alexanderstr")
85
85
  end
86
86
 
87
87
  context "when there are 10 or more child records" do
@@ -97,7 +97,7 @@ describe Mongoid::NestedAttributes do
97
97
  end
98
98
 
99
99
  it "preserves the order of the children" do
100
- person.addresses.map(&:number).should eq((0..10).to_a)
100
+ expect(person.addresses.map(&:number)).to eq((0..10).to_a)
101
101
  end
102
102
  end
103
103
  end
@@ -113,7 +113,7 @@ describe Mongoid::NestedAttributes do
113
113
  end
114
114
 
115
115
  it "sets the nested attributes" do
116
- video.person.title.should eq("Sir")
116
+ expect(video.person.title).to eq("Sir")
117
117
  end
118
118
  end
119
119
 
@@ -129,7 +129,7 @@ describe Mongoid::NestedAttributes do
129
129
  end
130
130
 
131
131
  it "sets the nested attributes" do
132
- person.game.name.should eq("Tron")
132
+ expect(person.game.name).to eq("Tron")
133
133
  end
134
134
  end
135
135
 
@@ -145,7 +145,7 @@ describe Mongoid::NestedAttributes do
145
145
  end
146
146
 
147
147
  it "sets the nested attributes" do
148
- person.posts.first.title.should eq("First")
148
+ expect(person.posts.first.title).to eq("First")
149
149
  end
150
150
  end
151
151
 
@@ -161,7 +161,7 @@ describe Mongoid::NestedAttributes do
161
161
  end
162
162
 
163
163
  it "sets the nested attributes" do
164
- person.preferences.first.name.should eq("First")
164
+ expect(person.preferences.first.name).to eq("First")
165
165
  end
166
166
  end
167
167
 
@@ -176,7 +176,7 @@ describe Mongoid::NestedAttributes do
176
176
  end
177
177
 
178
178
  it "sets the nested attributes" do
179
- post.person.title.should eq("Sir")
179
+ expect(post.person.title).to eq("Sir")
180
180
  end
181
181
  end
182
182
  end
@@ -210,11 +210,11 @@ describe Mongoid::NestedAttributes do
210
210
  end
211
211
 
212
212
  it "sets the child document" do
213
- person.name.last_name.should eq("Fischer")
213
+ expect(person.name.last_name).to eq("Fischer")
214
214
  end
215
215
 
216
216
  it "does not persist the child document" do
217
- person.name.should_not be_persisted
217
+ expect(person.name).to_not be_persisted
218
218
  end
219
219
 
220
220
  context "when saving the parent" do
@@ -225,7 +225,7 @@ describe Mongoid::NestedAttributes do
225
225
  end
226
226
 
227
227
  it "persists the child document" do
228
- person.name.should be_persisted
228
+ expect(person.name).to be_persisted
229
229
  end
230
230
  end
231
231
  end
@@ -255,7 +255,7 @@ describe Mongoid::NestedAttributes do
255
255
  end
256
256
 
257
257
  it "does not add the document" do
258
- person.name.should be_nil
258
+ expect(person.name).to be_nil
259
259
  end
260
260
  end
261
261
 
@@ -266,7 +266,7 @@ describe Mongoid::NestedAttributes do
266
266
  end
267
267
 
268
268
  it "adds the document" do
269
- person.name.first_name.should eq("Lang")
269
+ expect(person.name.first_name).to eq("Lang")
270
270
  end
271
271
  end
272
272
  end
@@ -293,7 +293,7 @@ describe Mongoid::NestedAttributes do
293
293
  end
294
294
 
295
295
  it "does not add the document" do
296
- person.name.should be_nil
296
+ expect(person.name).to be_nil
297
297
  end
298
298
  end
299
299
 
@@ -304,7 +304,7 @@ describe Mongoid::NestedAttributes do
304
304
  end
305
305
 
306
306
  it "adds the document" do
307
- person.name.first_name.should eq("Lang")
307
+ expect(person.name.first_name).to eq("Lang")
308
308
  end
309
309
  end
310
310
  end
@@ -326,7 +326,7 @@ describe Mongoid::NestedAttributes do
326
326
  end
327
327
 
328
328
  it "does not add the document" do
329
- product.seo.should_not be_persisted
329
+ expect(product.seo).to_not be_persisted
330
330
  end
331
331
  end
332
332
  end
@@ -341,7 +341,7 @@ describe Mongoid::NestedAttributes do
341
341
  end
342
342
 
343
343
  it "builds a new document" do
344
- person.name.first_name.should eq("Leo")
344
+ expect(person.name.first_name).to eq("Leo")
345
345
  end
346
346
  end
347
347
 
@@ -366,7 +366,7 @@ describe Mongoid::NestedAttributes do
366
366
  end
367
367
 
368
368
  it "does not build the document" do
369
- person.name.should be_nil
369
+ expect(person.name).to be_nil
370
370
  end
371
371
  end
372
372
 
@@ -377,7 +377,7 @@ describe Mongoid::NestedAttributes do
377
377
  end
378
378
 
379
379
  it "does not build the document" do
380
- person.name.should be_nil
380
+ expect(person.name).to be_nil
381
381
  end
382
382
  end
383
383
  end
@@ -399,7 +399,7 @@ describe Mongoid::NestedAttributes do
399
399
  end
400
400
 
401
401
  it "builds the document" do
402
- person.name.first_name.should eq("Leo")
402
+ expect(person.name.first_name).to eq("Leo")
403
403
  end
404
404
  end
405
405
  end
@@ -411,7 +411,7 @@ describe Mongoid::NestedAttributes do
411
411
  end
412
412
 
413
413
  it "does not build the document" do
414
- person.name.should be_nil
414
+ expect(person.name).to be_nil
415
415
  end
416
416
  end
417
417
 
@@ -425,7 +425,7 @@ describe Mongoid::NestedAttributes do
425
425
  end
426
426
 
427
427
  it "replaces the document" do
428
- person.name.first_name.should eq("Jack")
428
+ expect(person.name.first_name).to eq("Jack")
429
429
  end
430
430
  end
431
431
 
@@ -449,7 +449,7 @@ describe Mongoid::NestedAttributes do
449
449
  end
450
450
 
451
451
  it "does not replace the document" do
452
- person.name.first_name.should eq("Michael")
452
+ expect(person.name.first_name).to eq("Michael")
453
453
  end
454
454
  end
455
455
 
@@ -471,7 +471,7 @@ describe Mongoid::NestedAttributes do
471
471
  end
472
472
 
473
473
  it "replaces the document" do
474
- person.name.first_name.should eq("Jack")
474
+ expect(person.name.first_name).to eq("Jack")
475
475
  end
476
476
  end
477
477
  end
@@ -500,7 +500,7 @@ describe Mongoid::NestedAttributes do
500
500
  end
501
501
 
502
502
  it "updates the existing document" do
503
- person.name.first_name.should eq("Bob")
503
+ expect(person.name.first_name).to eq("Bob")
504
504
  end
505
505
  end
506
506
 
@@ -512,7 +512,7 @@ describe Mongoid::NestedAttributes do
512
512
  end
513
513
 
514
514
  it "updates the existing document" do
515
- person.name.first_name.should eq("Bob")
515
+ expect(person.name.first_name).to eq("Bob")
516
516
  end
517
517
  end
518
518
 
@@ -540,7 +540,7 @@ describe Mongoid::NestedAttributes do
540
540
  end
541
541
 
542
542
  it "destroys the existing document" do
543
- person.name.should be_nil
543
+ expect(person.name).to be_nil
544
544
  end
545
545
  end
546
546
 
@@ -568,11 +568,11 @@ describe Mongoid::NestedAttributes do
568
568
  end
569
569
 
570
570
  it "destroys the existing document" do
571
- owner.pet.should be_nil
571
+ expect(owner.pet).to be_nil
572
572
  end
573
573
 
574
574
  it "runs the destroy callbacks" do
575
- pet.destroy_flag.should be_true
575
+ expect(pet.destroy_flag).to be true
576
576
  end
577
577
  end
578
578
  end
@@ -588,7 +588,7 @@ describe Mongoid::NestedAttributes do
588
588
  end
589
589
 
590
590
  it "does not destroy the existing document" do
591
- person.name.should eq(name)
591
+ expect(person.name).to eq(name)
592
592
  end
593
593
  end
594
594
  end
@@ -614,7 +614,7 @@ describe Mongoid::NestedAttributes do
614
614
  end
615
615
 
616
616
  it "does not destroy the document" do
617
- person.name.should eq(name)
617
+ expect(person.name).to eq(name)
618
618
  end
619
619
  end
620
620
  end
@@ -642,7 +642,7 @@ describe Mongoid::NestedAttributes do
642
642
  end
643
643
 
644
644
  it "updates the existing document" do
645
- person.name.first_name.should eq("Ro")
645
+ expect(person.name.first_name).to eq("Ro")
646
646
  end
647
647
  end
648
648
 
@@ -650,11 +650,11 @@ describe Mongoid::NestedAttributes do
650
650
 
651
651
  before do
652
652
  person.name_attributes =
653
- { id: Moped::BSON::ObjectId.new.to_s, first_name: "Durran" }
653
+ { id: BSON::ObjectId.new.to_s, first_name: "Durran" }
654
654
  end
655
655
 
656
656
  it "updates the existing document" do
657
- person.name.first_name.should eq("Durran")
657
+ expect(person.name.first_name).to eq("Durran")
658
658
  end
659
659
  end
660
660
 
@@ -666,7 +666,7 @@ describe Mongoid::NestedAttributes do
666
666
  end
667
667
 
668
668
  it "destroys the existing document" do
669
- person.name.should be_nil
669
+ expect(person.name).to be_nil
670
670
  end
671
671
  end
672
672
  end
@@ -684,7 +684,7 @@ describe Mongoid::NestedAttributes do
684
684
  end
685
685
 
686
686
  it "updates the existing document" do
687
- person.quiz.topic.should eq("English")
687
+ expect(person.quiz.topic).to eq("English")
688
688
  end
689
689
  end
690
690
  end
@@ -706,8 +706,8 @@ describe Mongoid::NestedAttributes do
706
706
  end
707
707
 
708
708
  it "propagates invalidity to parent" do
709
- person.pet.should_not be_valid
710
- person.should_not be_valid
709
+ expect(person.pet).to_not be_valid
710
+ expect(person).to_not be_valid
711
711
  end
712
712
  end
713
713
 
@@ -724,7 +724,7 @@ describe Mongoid::NestedAttributes do
724
724
  end
725
725
 
726
726
  it "instantiates an object of the given type" do
727
- canvas.writer.class.should eq(HtmlWriter)
727
+ expect(canvas.writer.class).to eq(HtmlWriter)
728
728
  end
729
729
  end
730
730
  end
@@ -746,7 +746,7 @@ describe Mongoid::NestedAttributes do
746
746
  end
747
747
 
748
748
  it "builds a new document" do
749
- animal.person.title.should eq("Sir")
749
+ expect(animal.person.title).to eq("Sir")
750
750
  end
751
751
 
752
752
  end
@@ -770,7 +770,7 @@ describe Mongoid::NestedAttributes do
770
770
  end
771
771
 
772
772
  it "does not build a new document" do
773
- animal.person.should be_nil
773
+ expect(animal.person).to be_nil
774
774
  end
775
775
  end
776
776
 
@@ -791,7 +791,7 @@ describe Mongoid::NestedAttributes do
791
791
  end
792
792
 
793
793
  it "builds a new document" do
794
- animal.person.title.should eq("Sir")
794
+ expect(animal.person.title).to eq("Sir")
795
795
  end
796
796
  end
797
797
  end
@@ -812,7 +812,7 @@ describe Mongoid::NestedAttributes do
812
812
  end
813
813
 
814
814
  it "updates the existing document" do
815
- animal.person.title.should eq("Sir")
815
+ expect(animal.person.title).to eq("Sir")
816
816
  end
817
817
  end
818
818
  end
@@ -845,7 +845,7 @@ describe Mongoid::NestedAttributes do
845
845
  end
846
846
 
847
847
  it "destroys the existing document" do
848
- animal.person.should be_nil
848
+ expect(animal.person).to be_nil
849
849
  end
850
850
  end
851
851
  end
@@ -860,7 +860,7 @@ describe Mongoid::NestedAttributes do
860
860
  end
861
861
 
862
862
  it "does not destroy the existing document" do
863
- animal.person.should eq(person)
863
+ expect(animal.person).to eq(person)
864
864
  end
865
865
  end
866
866
  end
@@ -886,7 +886,7 @@ describe Mongoid::NestedAttributes do
886
886
  end
887
887
 
888
888
  it "does not delete the document" do
889
- animal.person.should eq(person)
889
+ expect(animal.person).to eq(person)
890
890
  end
891
891
  end
892
892
  end
@@ -909,7 +909,7 @@ describe Mongoid::NestedAttributes do
909
909
  end
910
910
 
911
911
  it "updates the existing document" do
912
- animal.person.title.should eq("Madam")
912
+ expect(animal.person.title).to eq("Madam")
913
913
  end
914
914
  end
915
915
 
@@ -917,11 +917,11 @@ describe Mongoid::NestedAttributes do
917
917
 
918
918
  before do
919
919
  animal.person_attributes =
920
- { id: Moped::BSON::ObjectId.new.to_s, title: "Madam" }
920
+ { id: BSON::ObjectId.new.to_s, title: "Madam" }
921
921
  end
922
922
 
923
923
  it "updates the existing document" do
924
- animal.person.title.should eq("Madam")
924
+ expect(animal.person.title).to eq("Madam")
925
925
  end
926
926
  end
927
927
 
@@ -933,7 +933,7 @@ describe Mongoid::NestedAttributes do
933
933
  end
934
934
 
935
935
  it "deletes the existing document" do
936
- animal.person.should be_nil
936
+ expect(animal.person).to be_nil
937
937
  end
938
938
  end
939
939
  end
@@ -955,8 +955,8 @@ describe Mongoid::NestedAttributes do
955
955
  end
956
956
 
957
957
  it "does not propagate invalidity to parent" do
958
- animal.person.should_not be_valid
959
- animal.should be_valid
958
+ expect(animal.person).to_not be_valid
959
+ expect(animal).to be_valid
960
960
  end
961
961
  end
962
962
  end
@@ -972,7 +972,7 @@ describe Mongoid::NestedAttributes do
972
972
  end
973
973
 
974
974
  it "instantiates an object of the given type" do
975
- tool.palette.class.should eq(BigPalette)
975
+ expect(tool.palette.class).to eq(BigPalette)
976
976
  end
977
977
  end
978
978
  end
@@ -1006,11 +1006,11 @@ describe Mongoid::NestedAttributes do
1006
1006
  end
1007
1007
 
1008
1008
  it "sets the child documents" do
1009
- person.addresses.first.street.should eq("Maybachufer")
1009
+ expect(person.addresses.first.street).to eq("Maybachufer")
1010
1010
  end
1011
1011
 
1012
1012
  it "does not persist the child documents" do
1013
- person.addresses.first.should_not be_persisted
1013
+ expect(person.addresses.first).to_not be_persisted
1014
1014
  end
1015
1015
 
1016
1016
  context "when saving the parent" do
@@ -1021,7 +1021,7 @@ describe Mongoid::NestedAttributes do
1021
1021
  end
1022
1022
 
1023
1023
  it "saves the child documents" do
1024
- person.addresses.first.should be_persisted
1024
+ expect(person.addresses.first).to be_persisted
1025
1025
  end
1026
1026
  end
1027
1027
  end
@@ -1039,14 +1039,6 @@ describe Mongoid::NestedAttributes do
1039
1039
  Address.new(street: "Kurfeurstendamm")
1040
1040
  end
1041
1041
 
1042
- let(:phone_one) do
1043
- ParanoidPhone.new(number: "1")
1044
- end
1045
-
1046
- let(:phone_two) do
1047
- ParanoidPhone.new(number: "2")
1048
- end
1049
-
1050
1042
  context "when a limit is specified" do
1051
1043
 
1052
1044
  before(:all) do
@@ -1090,7 +1082,7 @@ describe Mongoid::NestedAttributes do
1090
1082
  end
1091
1083
 
1092
1084
  it "sets the documents on the relation" do
1093
- person.addresses.size.should eq(2)
1085
+ expect(person.addresses.size).to eq(2)
1094
1086
  end
1095
1087
  end
1096
1088
 
@@ -1108,7 +1100,7 @@ describe Mongoid::NestedAttributes do
1108
1100
  end
1109
1101
 
1110
1102
  it "sets the documents on the relation" do
1111
- person.addresses.size.should eq(2)
1103
+ expect(person.addresses.size).to eq(2)
1112
1104
  end
1113
1105
  end
1114
1106
 
@@ -1144,11 +1136,11 @@ describe Mongoid::NestedAttributes do
1144
1136
  end
1145
1137
 
1146
1138
  it "runs the first child create callbacks" do
1147
- band.records.first.before_create_called.should be_true
1139
+ expect(band.records.first.before_create_called).to be true
1148
1140
  end
1149
1141
 
1150
1142
  it "runs the last child create callbacks" do
1151
- band.records.last.before_create_called.should be_true
1143
+ expect(band.records.last.before_create_called).to be true
1152
1144
  end
1153
1145
  end
1154
1146
  end
@@ -1173,15 +1165,15 @@ describe Mongoid::NestedAttributes do
1173
1165
  end
1174
1166
 
1175
1167
  it "updates the first existing document" do
1176
- person.addresses.first.street.should eq("Maybachufer")
1168
+ expect(person.addresses.first.street).to eq("Maybachufer")
1177
1169
  end
1178
1170
 
1179
1171
  it "updates the second existing document" do
1180
- person.addresses.second.street.should eq("Alexander Platz")
1172
+ expect(person.addresses.second.street).to eq("Alexander Platz")
1181
1173
  end
1182
1174
 
1183
1175
  it "does not add new documents" do
1184
- person.addresses.size.should eq(2)
1176
+ expect(person.addresses.size).to eq(2)
1185
1177
  end
1186
1178
  end
1187
1179
 
@@ -1198,15 +1190,15 @@ describe Mongoid::NestedAttributes do
1198
1190
  end
1199
1191
 
1200
1192
  it "updates the first existing document" do
1201
- person.addresses.collect { |a| a['street'] }.should include('Maybachufer')
1193
+ expect(person.addresses.collect { |a| a['street'] }).to include('Maybachufer')
1202
1194
  end
1203
1195
 
1204
1196
  it "updates the second existing document" do
1205
- person.addresses.collect { |a| a['street'] }.should include('Alexander Platz')
1197
+ expect(person.addresses.collect { |a| a['street'] }).to include('Alexander Platz')
1206
1198
  end
1207
1199
 
1208
1200
  it "does not add new documents" do
1209
- person.addresses.size.should eq(2)
1201
+ expect(person.addresses.size).to eq(2)
1210
1202
  end
1211
1203
  end
1212
1204
 
@@ -1221,15 +1213,15 @@ describe Mongoid::NestedAttributes do
1221
1213
  end
1222
1214
 
1223
1215
  it "updates the first existing document" do
1224
- person.addresses.collect { |a| a['street'] }.should include('Maybachufer')
1216
+ expect(person.addresses.collect { |a| a['street'] }).to include('Maybachufer')
1225
1217
  end
1226
1218
 
1227
1219
  it "updates the second existing document" do
1228
- person.addresses.collect { |a| a['street'] }.should include('Alexander Platz')
1220
+ expect(person.addresses.collect { |a| a['street'] }).to include('Alexander Platz')
1229
1221
  end
1230
1222
 
1231
1223
  it "does not add new documents" do
1232
- person.addresses.size.should eq(2)
1224
+ expect(person.addresses.size).to eq(2)
1233
1225
  end
1234
1226
  end
1235
1227
  end
@@ -1245,15 +1237,15 @@ describe Mongoid::NestedAttributes do
1245
1237
  end
1246
1238
 
1247
1239
  it "updates the first existing document" do
1248
- person.addresses.collect { |a| a['street'] }.should include('Maybachufer')
1240
+ expect(person.addresses.collect { |a| a['street'] }).to include('Maybachufer')
1249
1241
  end
1250
1242
 
1251
1243
  it "updates the second existing document" do
1252
- person.addresses.collect { |a| a['street'] }.should include('Alexander Platz')
1244
+ expect(person.addresses.collect { |a| a['street'] }).to include('Alexander Platz')
1253
1245
  end
1254
1246
 
1255
1247
  it "does not add new documents" do
1256
- person.addresses.size.should eq(2)
1248
+ expect(person.addresses.size).to eq(2)
1257
1249
  end
1258
1250
  end
1259
1251
 
@@ -1268,15 +1260,15 @@ describe Mongoid::NestedAttributes do
1268
1260
  end
1269
1261
 
1270
1262
  it "updates the first existing document" do
1271
- person.addresses.collect { |a| a['street'] }.should include('Maybachufer')
1263
+ expect(person.addresses.collect { |a| a['street'] }).to include('Maybachufer')
1272
1264
  end
1273
1265
 
1274
1266
  it "updates the second existing document" do
1275
- person.addresses.collect { |a| a['street'] }.should include('Alexander Platz')
1267
+ expect(person.addresses.collect { |a| a['street'] }).to include('Alexander Platz')
1276
1268
  end
1277
1269
 
1278
1270
  it "does not add new documents" do
1279
- person.addresses.size.should eq(2)
1271
+ expect(person.addresses.size).to eq(2)
1280
1272
  end
1281
1273
  end
1282
1274
 
@@ -1291,15 +1283,15 @@ describe Mongoid::NestedAttributes do
1291
1283
  end
1292
1284
 
1293
1285
  it "updates the first existing document" do
1294
- person.addresses.collect { |a| a['street'] }.should include('Maybachufer')
1286
+ expect(person.addresses.collect { |a| a['street'] }).to include('Maybachufer')
1295
1287
  end
1296
1288
 
1297
1289
  it "updates the second existing document" do
1298
- person.addresses.collect { |a| a['street'] }.should include('Alexander Platz')
1290
+ expect(person.addresses.collect { |a| a['street'] }).to include('Alexander Platz')
1299
1291
  end
1300
1292
 
1301
1293
  it "does not add new documents" do
1302
- person.addresses.size.should eq(2)
1294
+ expect(person.addresses.size).to eq(2)
1303
1295
  end
1304
1296
  end
1305
1297
 
@@ -1352,15 +1344,15 @@ describe Mongoid::NestedAttributes do
1352
1344
  end
1353
1345
 
1354
1346
  it "does not remove the child document" do
1355
- band.records.should_not be_empty
1347
+ expect(band.records).to_not be_empty
1356
1348
  end
1357
1349
 
1358
1350
  it "keeps the child flagged for destruction" do
1359
- record.should be_flagged_for_destroy
1351
+ expect(record).to be_flagged_for_destroy
1360
1352
  end
1361
1353
 
1362
1354
  it "does not persist any change" do
1363
- band.reload.records.should eq([ record ])
1355
+ expect(band.reload.records).to eq([ record ])
1364
1356
  end
1365
1357
  end
1366
1358
 
@@ -1389,11 +1381,11 @@ describe Mongoid::NestedAttributes do
1389
1381
  end
1390
1382
 
1391
1383
  it "deletes the child document" do
1392
- band.records.should be_empty
1384
+ expect(band.records).to be_empty
1393
1385
  end
1394
1386
 
1395
1387
  it "persists the changes" do
1396
- band.reload.records.should be_empty
1388
+ expect(band.reload.records).to be_empty
1397
1389
  end
1398
1390
  end
1399
1391
 
@@ -1415,31 +1407,6 @@ describe Mongoid::NestedAttributes do
1415
1407
 
1416
1408
  context "when the child returns false in a before callback" do
1417
1409
 
1418
- context "when the child is paranoid" do
1419
-
1420
- before(:all) do
1421
- Person.accepts_nested_attributes_for :paranoid_phones, allow_destroy: true
1422
- end
1423
-
1424
- after(:all) do
1425
- Person.send(:undef_method, :paranoid_phones=)
1426
- Person.accepts_nested_attributes_for :paranoid_phones
1427
- end
1428
-
1429
- let!(:phone) do
1430
- persisted.paranoid_phones.create
1431
- end
1432
-
1433
- before do
1434
- persisted.paranoid_phones_attributes =
1435
- { "foo" => { "id" => phone.id, "number" => 42, "_destroy" => true }}
1436
- end
1437
-
1438
- it "does not destroy the child" do
1439
- persisted.reload.paranoid_phones.should_not be_empty
1440
- end
1441
- end
1442
-
1443
1410
  context "when the child is not paranoid" do
1444
1411
 
1445
1412
  let(:actor) do
@@ -1457,7 +1424,7 @@ describe Mongoid::NestedAttributes do
1457
1424
  end
1458
1425
 
1459
1426
  it "does not destroy the child" do
1460
- actor.reload.things.should_not be_empty
1427
+ expect(actor.reload.things).to_not be_empty
1461
1428
  end
1462
1429
  end
1463
1430
  end
@@ -1490,11 +1457,11 @@ describe Mongoid::NestedAttributes do
1490
1457
  end
1491
1458
 
1492
1459
  it "destroys both children" do
1493
- from_db.appointments.should be_empty
1460
+ expect(from_db.appointments).to be_empty
1494
1461
  end
1495
1462
 
1496
1463
  it "persists the deletes" do
1497
- from_db.reload.appointments.should be_empty
1464
+ expect(from_db.reload.appointments).to be_empty
1498
1465
  end
1499
1466
  end
1500
1467
  end
@@ -1530,11 +1497,11 @@ describe Mongoid::NestedAttributes do
1530
1497
  end
1531
1498
 
1532
1499
  it "deletes the marked document" do
1533
- person.addresses.size.should eq(1)
1500
+ expect(person.addresses.size).to eq(1)
1534
1501
  end
1535
1502
 
1536
1503
  it "does not delete the unmarked document" do
1537
- person.addresses.first.street.should eq("Alexander Platz")
1504
+ expect(person.addresses.first.street).to eq("Alexander Platz")
1538
1505
  end
1539
1506
  end
1540
1507
 
@@ -1549,11 +1516,11 @@ describe Mongoid::NestedAttributes do
1549
1516
  end
1550
1517
 
1551
1518
  it "deletes the marked document" do
1552
- person.addresses.size.should eq(1)
1519
+ expect(person.addresses.size).to eq(1)
1553
1520
  end
1554
1521
 
1555
1522
  it "does not delete the unmarked document" do
1556
- person.addresses.first.street.should eq("Alexander Platz")
1523
+ expect(person.addresses.first.street).to eq("Alexander Platz")
1557
1524
  end
1558
1525
  end
1559
1526
  end
@@ -1578,51 +1545,51 @@ describe Mongoid::NestedAttributes do
1578
1545
  end
1579
1546
 
1580
1547
  it "does not remove the first document from the relation" do
1581
- persisted.addresses.size.should eq(3)
1548
+ expect(persisted.addresses.size).to eq(3)
1582
1549
  end
1583
1550
 
1584
1551
  it "flags the destroyed document for removal" do
1585
- address_one.should be_marked_for_destruction
1552
+ expect(address_one).to be_marked_for_destruction
1586
1553
  end
1587
1554
 
1588
1555
  it "does not delete the unmarked document" do
1589
- persisted.addresses.second.street.should eq(
1556
+ expect(persisted.addresses.second.street).to eq(
1590
1557
  "Alexander Platz"
1591
1558
  )
1592
1559
  end
1593
1560
 
1594
1561
  it "adds the new document to the relation" do
1595
- persisted.addresses.last.street.should eq(
1562
+ expect(persisted.addresses.last.street).to eq(
1596
1563
  "Potsdammer Platz"
1597
1564
  )
1598
1565
  end
1599
1566
 
1600
1567
  it "has the proper persisted count" do
1601
- persisted.addresses.count.should eq(2)
1568
+ expect(persisted.addresses.count).to eq(2)
1602
1569
  end
1603
1570
 
1604
1571
  it "does not delete the removed document" do
1605
- address_one.should_not be_destroyed
1572
+ expect(address_one).to_not be_destroyed
1606
1573
  end
1607
1574
 
1608
1575
  context "when saving the parent" do
1609
1576
 
1610
1577
  before do
1611
- persisted.with(safe: true).save
1578
+ persisted.save
1612
1579
  end
1613
1580
 
1614
1581
  it "deletes the marked document from the relation" do
1615
- persisted.reload.addresses.count.should eq(2)
1582
+ expect(persisted.reload.addresses.count).to eq(2)
1616
1583
  end
1617
1584
 
1618
1585
  it "does not delete the unmarked document" do
1619
- persisted.reload.addresses.first.street.should eq(
1586
+ expect(persisted.reload.addresses.first.street).to eq(
1620
1587
  "Alexander Platz"
1621
1588
  )
1622
1589
  end
1623
1590
 
1624
1591
  it "persists the new document to the relation" do
1625
- persisted.reload.addresses.last.street.should eq(
1592
+ expect(persisted.reload.addresses.last.street).to eq(
1626
1593
  "Potsdammer Platz"
1627
1594
  )
1628
1595
  end
@@ -1640,39 +1607,39 @@ describe Mongoid::NestedAttributes do
1640
1607
  end
1641
1608
 
1642
1609
  it "does not remove the first document from the relation" do
1643
- persisted.addresses.size.should eq(3)
1610
+ expect(persisted.addresses.size).to eq(3)
1644
1611
  end
1645
1612
 
1646
1613
  it "marks the first document for destruction" do
1647
- address_one.should be_marked_for_destruction
1614
+ expect(address_one).to be_marked_for_destruction
1648
1615
  end
1649
1616
 
1650
1617
  it "adds the new document to the relation" do
1651
- persisted.addresses.last.street.should eq(
1618
+ expect(persisted.addresses.last.street).to eq(
1652
1619
  "Potsdammer Platz"
1653
1620
  )
1654
1621
  end
1655
1622
 
1656
1623
  it "has the proper persisted count" do
1657
- persisted.addresses.count.should eq(2)
1624
+ expect(persisted.addresses.count).to eq(2)
1658
1625
  end
1659
1626
 
1660
1627
  it "does not delete the removed document" do
1661
- address_one.should_not be_destroyed
1628
+ expect(address_one).to_not be_destroyed
1662
1629
  end
1663
1630
 
1664
1631
  context "when saving the parent" do
1665
1632
 
1666
1633
  before do
1667
- persisted.with(safe: true).save
1634
+ persisted.save
1668
1635
  end
1669
1636
 
1670
1637
  it "deletes the marked document from the relation" do
1671
- persisted.reload.addresses.count.should eq(2)
1638
+ expect(persisted.reload.addresses.count).to eq(2)
1672
1639
  end
1673
1640
 
1674
1641
  it "persists the new document to the relation" do
1675
- persisted.reload.addresses.last.street.should eq(
1642
+ expect(persisted.reload.addresses.last.street).to eq(
1676
1643
  "Potsdammer Platz"
1677
1644
  )
1678
1645
  end
@@ -1695,91 +1662,11 @@ describe Mongoid::NestedAttributes do
1695
1662
  end
1696
1663
 
1697
1664
  it "does not delete the marked document" do
1698
- person.addresses.size.should eq(2)
1665
+ expect(person.addresses.size).to eq(2)
1699
1666
  end
1700
1667
 
1701
1668
  it "does not delete the unmarked document" do
1702
- person.addresses.last.street.should eq("Alexander Platz")
1703
- end
1704
- end
1705
- end
1706
- end
1707
-
1708
- context "when the child is paranoid" do
1709
-
1710
- before(:all) do
1711
- Person.send(:undef_method, :paranoid_phones_attributes=)
1712
- Person.accepts_nested_attributes_for :paranoid_phones,
1713
- allow_destroy: true
1714
- end
1715
-
1716
- after(:all) do
1717
- Person.send(:undef_method, :paranoid_phones_attributes=)
1718
- Person.accepts_nested_attributes_for :paranoid_phones
1719
- end
1720
-
1721
- [ 1, "1", true, "true" ].each do |truth|
1722
-
1723
- context "when passed a #{truth} with destroy" do
1724
-
1725
- context "when the parent is persisted" do
1726
-
1727
- let!(:persisted) do
1728
- Person.create do |p|
1729
- p.paranoid_phones << [ phone_one, phone_two ]
1730
- end
1731
- end
1732
-
1733
- context "when setting, pulling, and pushing in one op" do
1734
-
1735
- before do
1736
- persisted.paranoid_phones_attributes =
1737
- {
1738
- "bar" => { "id" => phone_one.id, "_destroy" => truth },
1739
- "foo" => { "id" => phone_two.id, "number" => "3" },
1740
- "baz" => { "number" => "4" }
1741
- }
1742
- end
1743
-
1744
- it "removes the first document from the relation" do
1745
- persisted.paranoid_phones.size.should eq(2)
1746
- end
1747
-
1748
- it "does not delete the unmarked document" do
1749
- persisted.paranoid_phones.first.number.should eq("3")
1750
- end
1751
-
1752
- it "adds the new document to the relation" do
1753
- persisted.paranoid_phones.last.number.should eq("4")
1754
- end
1755
-
1756
- it "has the proper persisted count" do
1757
- persisted.paranoid_phones.count.should eq(1)
1758
- end
1759
-
1760
- it "soft deletes the removed document" do
1761
- phone_one.should be_destroyed
1762
- end
1763
-
1764
- context "when saving the parent" do
1765
-
1766
- before do
1767
- persisted.with(safe: true).save
1768
- end
1769
-
1770
- it "deletes the marked document from the relation" do
1771
- persisted.reload.paranoid_phones.count.should eq(2)
1772
- end
1773
-
1774
- it "does not delete the unmarked document" do
1775
- persisted.reload.paranoid_phones.first.number.should eq("3")
1776
- end
1777
-
1778
- it "persists the new document to the relation" do
1779
- persisted.reload.paranoid_phones.last.number.should eq("4")
1780
- end
1781
- end
1782
- end
1669
+ expect(person.addresses.last.street).to eq("Alexander Platz")
1783
1670
  end
1784
1671
  end
1785
1672
  end
@@ -1812,15 +1699,15 @@ describe Mongoid::NestedAttributes do
1812
1699
  end
1813
1700
 
1814
1701
  it "does not ignore the marked document" do
1815
- person.addresses.first.street.should eq("Maybachufer")
1702
+ expect(person.addresses.first.street).to eq("Maybachufer")
1816
1703
  end
1817
1704
 
1818
1705
  it "does not delete the unmarked document" do
1819
- person.addresses.last.street.should eq("Alexander Platz")
1706
+ expect(person.addresses.last.street).to eq("Alexander Platz")
1820
1707
  end
1821
1708
 
1822
1709
  it "does not add additional documents" do
1823
- person.addresses.size.should eq(2)
1710
+ expect(person.addresses.size).to eq(2)
1824
1711
  end
1825
1712
  end
1826
1713
  end
@@ -1838,11 +1725,11 @@ describe Mongoid::NestedAttributes do
1838
1725
  end
1839
1726
 
1840
1727
  it "does not delete the marked document" do
1841
- person.addresses.size.should eq(2)
1728
+ expect(person.addresses.size).to eq(2)
1842
1729
  end
1843
1730
 
1844
1731
  it "does not delete the unmarked document" do
1845
- person.addresses.last.street.should eq("Alexander Platz")
1732
+ expect(person.addresses.last.street).to eq("Alexander Platz")
1846
1733
  end
1847
1734
  end
1848
1735
  end
@@ -1869,15 +1756,15 @@ describe Mongoid::NestedAttributes do
1869
1756
  end
1870
1757
 
1871
1758
  it "does not ignore the marked document" do
1872
- person.addresses.first.street.should eq("Maybachufer")
1759
+ expect(person.addresses.first.street).to eq("Maybachufer")
1873
1760
  end
1874
1761
 
1875
1762
  it "does not delete the unmarked document" do
1876
- person.addresses.last.street.should eq("Alexander Platz")
1763
+ expect(person.addresses.last.street).to eq("Alexander Platz")
1877
1764
  end
1878
1765
 
1879
1766
  it "does not add additional documents" do
1880
- person.addresses.size.should eq(2)
1767
+ expect(person.addresses.size).to eq(2)
1881
1768
  end
1882
1769
  end
1883
1770
  end
@@ -1895,11 +1782,11 @@ describe Mongoid::NestedAttributes do
1895
1782
  end
1896
1783
 
1897
1784
  it "does not delete the marked document" do
1898
- person.addresses.size.should eq(2)
1785
+ expect(person.addresses.size).to eq(2)
1899
1786
  end
1900
1787
 
1901
1788
  it "does not delete the unmarked document" do
1902
- person.addresses.last.street.should eq("Alexander Platz")
1789
+ expect(person.addresses.last.street).to eq("Alexander Platz")
1903
1790
  end
1904
1791
  end
1905
1792
  end
@@ -1922,23 +1809,23 @@ describe Mongoid::NestedAttributes do
1922
1809
  end
1923
1810
 
1924
1811
  it "builds a new first document" do
1925
- person.addresses.first.street.should eq("Frederichstrasse")
1812
+ expect(person.addresses.first.street).to eq("Frederichstrasse")
1926
1813
  end
1927
1814
 
1928
1815
  it "builds a new second document" do
1929
- person.addresses.second.street.should eq("Alexander Platz")
1816
+ expect(person.addresses.second.street).to eq("Alexander Platz")
1930
1817
  end
1931
1818
 
1932
1819
  it "builds a new third document" do
1933
- person.addresses.third.street.should eq("Maybachufer")
1820
+ expect(person.addresses.third.street).to eq("Maybachufer")
1934
1821
  end
1935
1822
 
1936
1823
  it "does not add extra documents" do
1937
- person.addresses.size.should eq(3)
1824
+ expect(person.addresses.size).to eq(3)
1938
1825
  end
1939
1826
 
1940
1827
  it "adds the documents in the sorted hash key order" do
1941
- person.addresses.map(&:street).should eq(
1828
+ expect(person.addresses.map(&:street)).to eq(
1942
1829
  [ "Frederichstrasse", "Alexander Platz", "Maybachufer" ]
1943
1830
  )
1944
1831
  end
@@ -1965,7 +1852,7 @@ describe Mongoid::NestedAttributes do
1965
1852
  end
1966
1853
 
1967
1854
  it "does not add the new document" do
1968
- person.addresses.should be_empty
1855
+ expect(person.addresses).to be_empty
1969
1856
  end
1970
1857
  end
1971
1858
 
@@ -1977,11 +1864,11 @@ describe Mongoid::NestedAttributes do
1977
1864
  end
1978
1865
 
1979
1866
  it "adds the new document" do
1980
- person.addresses.size.should eq(1)
1867
+ expect(person.addresses.size).to eq(1)
1981
1868
  end
1982
1869
 
1983
1870
  it "sets the correct attributes" do
1984
- person.addresses.first.street.should eq("Maybachufer")
1871
+ expect(person.addresses.first.street).to eq("Maybachufer")
1985
1872
  end
1986
1873
  end
1987
1874
  end
@@ -2007,7 +1894,7 @@ describe Mongoid::NestedAttributes do
2007
1894
  end
2008
1895
 
2009
1896
  it "does not add the new document" do
2010
- person.addresses.should be_empty
1897
+ expect(person.addresses).to be_empty
2011
1898
  end
2012
1899
  end
2013
1900
 
@@ -2019,11 +1906,11 @@ describe Mongoid::NestedAttributes do
2019
1906
  end
2020
1907
 
2021
1908
  it "adds the new document" do
2022
- person.addresses.size.should eq(1)
1909
+ expect(person.addresses.size).to eq(1)
2023
1910
  end
2024
1911
 
2025
1912
  it "sets the correct attributes" do
2026
- person.addresses.first.street.should eq("Maybachufer")
1913
+ expect(person.addresses.first.street).to eq("Maybachufer")
2027
1914
  end
2028
1915
  end
2029
1916
  end
@@ -2055,11 +1942,11 @@ describe Mongoid::NestedAttributes do
2055
1942
  end
2056
1943
 
2057
1944
  it "ignores the the marked document" do
2058
- person.addresses.size.should eq(1)
1945
+ expect(person.addresses.size).to eq(1)
2059
1946
  end
2060
1947
 
2061
1948
  it "adds the new unmarked document" do
2062
- person.addresses.first.street.should eq("Alexander Platz")
1949
+ expect(person.addresses.first.street).to eq("Alexander Platz")
2063
1950
  end
2064
1951
  end
2065
1952
  end
@@ -2077,15 +1964,15 @@ describe Mongoid::NestedAttributes do
2077
1964
  end
2078
1965
 
2079
1966
  it "adds the new marked document" do
2080
- person.addresses.first.street.should eq("Maybachufer")
1967
+ expect(person.addresses.first.street).to eq("Maybachufer")
2081
1968
  end
2082
1969
 
2083
1970
  it "adds the new unmarked document" do
2084
- person.addresses.last.street.should eq("Alexander Platz")
1971
+ expect(person.addresses.last.street).to eq("Alexander Platz")
2085
1972
  end
2086
1973
 
2087
1974
  it "does not add extra documents" do
2088
- person.addresses.size.should eq(2)
1975
+ expect(person.addresses.size).to eq(2)
2089
1976
  end
2090
1977
  end
2091
1978
  end
@@ -2116,15 +2003,15 @@ describe Mongoid::NestedAttributes do
2116
2003
  end
2117
2004
 
2118
2005
  it "adds the the marked document" do
2119
- person.addresses.first.street.should eq("Maybachufer")
2006
+ expect(person.addresses.first.street).to eq("Maybachufer")
2120
2007
  end
2121
2008
 
2122
2009
  it "adds the new unmarked document" do
2123
- person.addresses.last.street.should eq("Alexander Platz")
2010
+ expect(person.addresses.last.street).to eq("Alexander Platz")
2124
2011
  end
2125
2012
 
2126
2013
  it "adds the correct number of documents" do
2127
- person.addresses.size.should eq(2)
2014
+ expect(person.addresses.size).to eq(2)
2128
2015
  end
2129
2016
  end
2130
2017
  end
@@ -2142,15 +2029,15 @@ describe Mongoid::NestedAttributes do
2142
2029
  end
2143
2030
 
2144
2031
  it "adds the new marked document" do
2145
- person.addresses.first.street.should eq("Maybachufer")
2032
+ expect(person.addresses.first.street).to eq("Maybachufer")
2146
2033
  end
2147
2034
 
2148
2035
  it "adds the new unmarked document" do
2149
- person.addresses.last.street.should eq("Alexander Platz")
2036
+ expect(person.addresses.last.street).to eq("Alexander Platz")
2150
2037
  end
2151
2038
 
2152
2039
  it "does not add extra documents" do
2153
- person.addresses.size.should eq(2)
2040
+ expect(person.addresses.size).to eq(2)
2154
2041
  end
2155
2042
  end
2156
2043
  end
@@ -2176,15 +2063,15 @@ describe Mongoid::NestedAttributes do
2176
2063
  end
2177
2064
 
2178
2065
  it "adds the the marked document" do
2179
- person.addresses.first.street.should eq("Maybachufer")
2066
+ expect(person.addresses.first.street).to eq("Maybachufer")
2180
2067
  end
2181
2068
 
2182
2069
  it "adds the new unmarked document" do
2183
- person.addresses.last.street.should eq("Alexander Platz")
2070
+ expect(person.addresses.last.street).to eq("Alexander Platz")
2184
2071
  end
2185
2072
 
2186
2073
  it "adds the correct number of documents" do
2187
- person.addresses.size.should eq(2)
2074
+ expect(person.addresses.size).to eq(2)
2188
2075
  end
2189
2076
  end
2190
2077
  end
@@ -2202,15 +2089,15 @@ describe Mongoid::NestedAttributes do
2202
2089
  end
2203
2090
 
2204
2091
  it "adds the new marked document" do
2205
- person.addresses.first.street.should eq("Maybachufer")
2092
+ expect(person.addresses.first.street).to eq("Maybachufer")
2206
2093
  end
2207
2094
 
2208
2095
  it "adds the new unmarked document" do
2209
- person.addresses.last.street.should eq("Alexander Platz")
2096
+ expect(person.addresses.last.street).to eq("Alexander Platz")
2210
2097
  end
2211
2098
 
2212
2099
  it "does not add extra documents" do
2213
- person.addresses.size.should eq(2)
2100
+ expect(person.addresses.size).to eq(2)
2214
2101
  end
2215
2102
  end
2216
2103
  end
@@ -2238,7 +2125,7 @@ describe Mongoid::NestedAttributes do
2238
2125
  end
2239
2126
 
2240
2127
  it "does not add the document" do
2241
- person.addresses.should be_empty
2128
+ expect(person.addresses).to be_empty
2242
2129
  end
2243
2130
  end
2244
2131
  end
@@ -2261,8 +2148,8 @@ describe Mongoid::NestedAttributes do
2261
2148
  end
2262
2149
 
2263
2150
  it "propagates invalidity to parent" do
2264
- person.addresses.first.should_not be_valid
2265
- person.should_not be_valid
2151
+ expect(person.addresses.first).to_not be_valid
2152
+ expect(person).to_not be_valid
2266
2153
  end
2267
2154
  end
2268
2155
 
@@ -2283,7 +2170,7 @@ describe Mongoid::NestedAttributes do
2283
2170
  end
2284
2171
 
2285
2172
  it "instantiates an object of the given type" do
2286
- canvas.shapes.map(&:class).should eq([Square, Circle])
2173
+ expect(canvas.shapes.map(&:class)).to eq([Square, Circle])
2287
2174
  end
2288
2175
  end
2289
2176
  end
@@ -2314,7 +2201,7 @@ describe Mongoid::NestedAttributes do
2314
2201
  end
2315
2202
 
2316
2203
  it "does not add the document" do
2317
- person.game.should be_nil
2204
+ expect(person.game).to be_nil
2318
2205
  end
2319
2206
  end
2320
2207
 
@@ -2325,7 +2212,7 @@ describe Mongoid::NestedAttributes do
2325
2212
  end
2326
2213
 
2327
2214
  it "adds the document" do
2328
- person.game.name.should eq("Tron")
2215
+ expect(person.game.name).to eq("Tron")
2329
2216
  end
2330
2217
  end
2331
2218
  end
@@ -2350,7 +2237,7 @@ describe Mongoid::NestedAttributes do
2350
2237
  end
2351
2238
 
2352
2239
  it "does not add the document" do
2353
- person.game.should be_nil
2240
+ expect(person.game).to be_nil
2354
2241
  end
2355
2242
  end
2356
2243
 
@@ -2361,7 +2248,7 @@ describe Mongoid::NestedAttributes do
2361
2248
  end
2362
2249
 
2363
2250
  it "adds the document" do
2364
- person.game.name.should eq("Tron")
2251
+ expect(person.game.name).to eq("Tron")
2365
2252
  end
2366
2253
  end
2367
2254
  end
@@ -2375,7 +2262,7 @@ describe Mongoid::NestedAttributes do
2375
2262
  end
2376
2263
 
2377
2264
  it "builds a new document" do
2378
- person.game.name.should eq("Tron")
2265
+ expect(person.game.name).to eq("Tron")
2379
2266
  end
2380
2267
  end
2381
2268
 
@@ -2398,7 +2285,7 @@ describe Mongoid::NestedAttributes do
2398
2285
  end
2399
2286
 
2400
2287
  it "does not build the document" do
2401
- person.game.should be_nil
2288
+ expect(person.game).to be_nil
2402
2289
  end
2403
2290
  end
2404
2291
 
@@ -2419,7 +2306,7 @@ describe Mongoid::NestedAttributes do
2419
2306
  end
2420
2307
 
2421
2308
  it "builds the document" do
2422
- person.game.name.should eq("Tron")
2309
+ expect(person.game.name).to eq("Tron")
2423
2310
  end
2424
2311
  end
2425
2312
  end
@@ -2431,7 +2318,7 @@ describe Mongoid::NestedAttributes do
2431
2318
  end
2432
2319
 
2433
2320
  it "does not build the document" do
2434
- person.game.should be_nil
2321
+ expect(person.game).to be_nil
2435
2322
  end
2436
2323
  end
2437
2324
 
@@ -2445,7 +2332,7 @@ describe Mongoid::NestedAttributes do
2445
2332
  end
2446
2333
 
2447
2334
  it "replaces the document" do
2448
- person.game.name.should eq("Pong")
2335
+ expect(person.game.name).to eq("Pong")
2449
2336
  end
2450
2337
  end
2451
2338
 
@@ -2461,7 +2348,7 @@ describe Mongoid::NestedAttributes do
2461
2348
  end
2462
2349
 
2463
2350
  it "persists the attribute changes" do
2464
- pizza.reload.topping.name.should eq("onions")
2351
+ expect(pizza.reload.topping.name).to eq("onions")
2465
2352
  end
2466
2353
  end
2467
2354
 
@@ -2485,7 +2372,7 @@ describe Mongoid::NestedAttributes do
2485
2372
  end
2486
2373
 
2487
2374
  it "does not replace the document" do
2488
- person.game.name.should eq("Tron")
2375
+ expect(person.game.name).to eq("Tron")
2489
2376
  end
2490
2377
  end
2491
2378
 
@@ -2507,7 +2394,7 @@ describe Mongoid::NestedAttributes do
2507
2394
  end
2508
2395
 
2509
2396
  it "replaces the document" do
2510
- person.game.name.should eq("Pong")
2397
+ expect(person.game.name).to eq("Pong")
2511
2398
  end
2512
2399
  end
2513
2400
  end
@@ -2536,7 +2423,7 @@ describe Mongoid::NestedAttributes do
2536
2423
  end
2537
2424
 
2538
2425
  it "updates the existing document" do
2539
- person.game.name.should eq("Pong")
2426
+ expect(person.game.name).to eq("Pong")
2540
2427
  end
2541
2428
  end
2542
2429
 
@@ -2548,7 +2435,7 @@ describe Mongoid::NestedAttributes do
2548
2435
  end
2549
2436
 
2550
2437
  it "updates the existing document" do
2551
- person.game.name.should eq("Pong")
2438
+ expect(person.game.name).to eq("Pong")
2552
2439
  end
2553
2440
  end
2554
2441
 
@@ -2574,7 +2461,7 @@ describe Mongoid::NestedAttributes do
2574
2461
  end
2575
2462
 
2576
2463
  it "destroys the existing document" do
2577
- person.game.should be_nil
2464
+ expect(person.game).to be_nil
2578
2465
  end
2579
2466
  end
2580
2467
  end
@@ -2589,7 +2476,7 @@ describe Mongoid::NestedAttributes do
2589
2476
  end
2590
2477
 
2591
2478
  it "does not destroy the existing document" do
2592
- person.game.should eq(game)
2479
+ expect(person.game).to eq(game)
2593
2480
  end
2594
2481
  end
2595
2482
  end
@@ -2615,7 +2502,7 @@ describe Mongoid::NestedAttributes do
2615
2502
  end
2616
2503
 
2617
2504
  it "does not destroy the document" do
2618
- person.game.should eq(game)
2505
+ expect(person.game).to eq(game)
2619
2506
  end
2620
2507
  end
2621
2508
  end
@@ -2643,7 +2530,7 @@ describe Mongoid::NestedAttributes do
2643
2530
  end
2644
2531
 
2645
2532
  it "updates the existing document" do
2646
- person.game.name.should eq("Donkey Kong")
2533
+ expect(person.game.name).to eq("Donkey Kong")
2647
2534
  end
2648
2535
  end
2649
2536
 
@@ -2651,11 +2538,11 @@ describe Mongoid::NestedAttributes do
2651
2538
 
2652
2539
  before do
2653
2540
  person.game_attributes =
2654
- { id: Moped::BSON::ObjectId.new.to_s, name: "Pong" }
2541
+ { id: BSON::ObjectId.new.to_s, name: "Pong" }
2655
2542
  end
2656
2543
 
2657
2544
  it "updates the existing document" do
2658
- person.game.name.should eq("Pong")
2545
+ expect(person.game.name).to eq("Pong")
2659
2546
  end
2660
2547
  end
2661
2548
 
@@ -2667,7 +2554,7 @@ describe Mongoid::NestedAttributes do
2667
2554
  end
2668
2555
 
2669
2556
  it "destroys the existing document" do
2670
- person.game.should be_nil
2557
+ expect(person.game).to be_nil
2671
2558
  end
2672
2559
  end
2673
2560
  end
@@ -2690,8 +2577,8 @@ describe Mongoid::NestedAttributes do
2690
2577
  end
2691
2578
 
2692
2579
  it "propagates invalidity to parent" do
2693
- person.game.should_not be_valid
2694
- person.should_not be_valid
2580
+ expect(person.game).to_not be_valid
2581
+ expect(person).to_not be_valid
2695
2582
  end
2696
2583
  end
2697
2584
 
@@ -2708,7 +2595,7 @@ describe Mongoid::NestedAttributes do
2708
2595
  end
2709
2596
 
2710
2597
  it "instantiates an object of the given type" do
2711
- driver.vehicle.class.should eq(Truck)
2598
+ expect(driver.vehicle.class).to eq(Truck)
2712
2599
  end
2713
2600
  end
2714
2601
  end
@@ -2730,7 +2617,7 @@ describe Mongoid::NestedAttributes do
2730
2617
  end
2731
2618
 
2732
2619
  it "builds a new document" do
2733
- game.person.title.should eq("Sir")
2620
+ expect(game.person.title).to eq("Sir")
2734
2621
  end
2735
2622
 
2736
2623
  end
@@ -2754,7 +2641,7 @@ describe Mongoid::NestedAttributes do
2754
2641
  end
2755
2642
 
2756
2643
  it "does not build a new document" do
2757
- game.person.should be_nil
2644
+ expect(game.person).to be_nil
2758
2645
  end
2759
2646
  end
2760
2647
 
@@ -2775,7 +2662,7 @@ describe Mongoid::NestedAttributes do
2775
2662
  end
2776
2663
 
2777
2664
  it "builds a new document" do
2778
- game.person.title.should eq("Sir")
2665
+ expect(game.person.title).to eq("Sir")
2779
2666
  end
2780
2667
  end
2781
2668
  end
@@ -2796,7 +2683,7 @@ describe Mongoid::NestedAttributes do
2796
2683
  end
2797
2684
 
2798
2685
  it "updates the existing document" do
2799
- game.person.title.should eq("Sir")
2686
+ expect(game.person.title).to eq("Sir")
2800
2687
  end
2801
2688
  end
2802
2689
  end
@@ -2829,7 +2716,7 @@ describe Mongoid::NestedAttributes do
2829
2716
  end
2830
2717
 
2831
2718
  it "destroys the existing document" do
2832
- game.person.should be_nil
2719
+ expect(game.person).to be_nil
2833
2720
  end
2834
2721
  end
2835
2722
  end
@@ -2844,7 +2731,7 @@ describe Mongoid::NestedAttributes do
2844
2731
  end
2845
2732
 
2846
2733
  it "does not destroy the existing document" do
2847
- game.person.should eq(person)
2734
+ expect(game.person).to eq(person)
2848
2735
  end
2849
2736
  end
2850
2737
  end
@@ -2870,7 +2757,7 @@ describe Mongoid::NestedAttributes do
2870
2757
  end
2871
2758
 
2872
2759
  it "does not delete the document" do
2873
- game.person.should eq(person)
2760
+ expect(game.person).to eq(person)
2874
2761
  end
2875
2762
  end
2876
2763
  end
@@ -2893,7 +2780,7 @@ describe Mongoid::NestedAttributes do
2893
2780
  end
2894
2781
 
2895
2782
  it "updates the existing document" do
2896
- game.person.title.should eq("Madam")
2783
+ expect(game.person.title).to eq("Madam")
2897
2784
  end
2898
2785
  end
2899
2786
 
@@ -2901,11 +2788,11 @@ describe Mongoid::NestedAttributes do
2901
2788
 
2902
2789
  before do
2903
2790
  game.person_attributes =
2904
- { id: Moped::BSON::ObjectId.new.to_s, title: "Madam" }
2791
+ { id: BSON::ObjectId.new.to_s, title: "Madam" }
2905
2792
  end
2906
2793
 
2907
2794
  it "updates the existing document" do
2908
- game.person.title.should eq("Madam")
2795
+ expect(game.person.title).to eq("Madam")
2909
2796
  end
2910
2797
  end
2911
2798
 
@@ -2917,7 +2804,7 @@ describe Mongoid::NestedAttributes do
2917
2804
  end
2918
2805
 
2919
2806
  it "deletes the existing document" do
2920
- game.person.should be_nil
2807
+ expect(game.person).to be_nil
2921
2808
  end
2922
2809
  end
2923
2810
  end
@@ -2939,8 +2826,8 @@ describe Mongoid::NestedAttributes do
2939
2826
  end
2940
2827
 
2941
2828
  it "propagates invalidity to parent" do
2942
- game.person.should_not be_valid
2943
- game.should_not be_valid
2829
+ expect(game.person).to_not be_valid
2830
+ expect(game).to_not be_valid
2944
2831
  end
2945
2832
  end
2946
2833
  end
@@ -2958,7 +2845,7 @@ describe Mongoid::NestedAttributes do
2958
2845
  end
2959
2846
 
2960
2847
  it "instantiates an object of the given type" do
2961
- vehicle.driver.class.should eq(Learner)
2848
+ expect(vehicle.driver.class).to eq(Learner)
2962
2849
  end
2963
2850
  end
2964
2851
  end
@@ -3020,11 +2907,11 @@ describe Mongoid::NestedAttributes do
3020
2907
  end
3021
2908
 
3022
2909
  it "sets the documents on the relation" do
3023
- person.posts.size.should eq(2)
2910
+ expect(person.posts.size).to eq(2)
3024
2911
  end
3025
2912
 
3026
2913
  it "does not persist the new documents" do
3027
- person.posts.count.should eq(0)
2914
+ expect(person.posts.count).to eq(0)
3028
2915
  end
3029
2916
  end
3030
2917
  end
@@ -3054,15 +2941,15 @@ describe Mongoid::NestedAttributes do
3054
2941
  context "when reloading the document" do
3055
2942
 
3056
2943
  it "updates the first existing document" do
3057
- person.posts(true).first.title.should eq("First")
2944
+ expect(person.posts(true).first.title).to eq("First")
3058
2945
  end
3059
2946
 
3060
2947
  it "updates the second existing document" do
3061
- person.posts(true).last.title.should eq("Second")
2948
+ expect(person.posts(true).last.title).to eq("Second")
3062
2949
  end
3063
2950
 
3064
2951
  it "does not add new documents" do
3065
- person.posts(true).size.should eq(2)
2952
+ expect(person.posts(true).size).to eq(2)
3066
2953
  end
3067
2954
  end
3068
2955
 
@@ -3076,7 +2963,7 @@ describe Mongoid::NestedAttributes do
3076
2963
  expect {
3077
2964
  person.posts_attributes =
3078
2965
  { "0" =>
3079
- { "id" => Moped::BSON::ObjectId.new.to_s, "title" => "Rogue" }
2966
+ { "id" => BSON::ObjectId.new.to_s, "title" => "Rogue" }
3080
2967
  }
3081
2968
  }.to raise_error(Mongoid::Errors::DocumentNotFound)
3082
2969
  end
@@ -3101,7 +2988,7 @@ describe Mongoid::NestedAttributes do
3101
2988
  end
3102
2989
 
3103
2990
  it "does not perist the invalid value" do
3104
- post_two.reload.title.should eq("First response")
2991
+ expect(post_two.reload.title).to eq("First response")
3105
2992
  end
3106
2993
  end
3107
2994
  end
@@ -3148,11 +3035,11 @@ describe Mongoid::NestedAttributes do
3148
3035
  context "when reloading the documents" do
3149
3036
 
3150
3037
  it "deletes the marked document" do
3151
- person.posts(true).size.should eq(1)
3038
+ expect(person.posts(true).size).to eq(1)
3152
3039
  end
3153
3040
 
3154
3041
  it "does not delete the unmarked document" do
3155
- person.posts(true).first.title.should eq("My Blog")
3042
+ expect(person.posts(true).first.title).to eq("My Blog")
3156
3043
  end
3157
3044
  end
3158
3045
  end
@@ -3173,11 +3060,11 @@ describe Mongoid::NestedAttributes do
3173
3060
  context "when reloading the document" do
3174
3061
 
3175
3062
  it "does not delete the marked document" do
3176
- person.posts(true).size.should eq(2)
3063
+ expect(person.posts(true).size).to eq(2)
3177
3064
  end
3178
3065
 
3179
3066
  it "does not delete the unmarked document" do
3180
- person.posts(true).map(&:title).should include("My Blog")
3067
+ expect(person.posts(true).map(&:title)).to include("My Blog")
3181
3068
  end
3182
3069
  end
3183
3070
  end
@@ -3212,15 +3099,15 @@ describe Mongoid::NestedAttributes do
3212
3099
  context "when reloading the document" do
3213
3100
 
3214
3101
  it "does not ignore the marked document" do
3215
- person.posts(true).first.title.should eq("Another Title")
3102
+ expect(person.posts(true).first.title).to eq("Another Title")
3216
3103
  end
3217
3104
 
3218
3105
  it "does not delete the unmarked document" do
3219
- person.posts(true).last.title.should eq("New Title")
3106
+ expect(person.posts(true).last.title).to eq("New Title")
3220
3107
  end
3221
3108
 
3222
3109
  it "does not add additional documents" do
3223
- person.posts(true).size.should eq(2)
3110
+ expect(person.posts(true).size).to eq(2)
3224
3111
  end
3225
3112
  end
3226
3113
  end
@@ -3241,11 +3128,11 @@ describe Mongoid::NestedAttributes do
3241
3128
  context "when reloading the documents" do
3242
3129
 
3243
3130
  it "does not delete the marked document" do
3244
- person.posts(true).size.should eq(2)
3131
+ expect(person.posts(true).size).to eq(2)
3245
3132
  end
3246
3133
 
3247
3134
  it "does not delete the unmarked document" do
3248
- person.posts(true).last.title.should eq("New Title")
3135
+ expect(person.posts(true).last.title).to eq("New Title")
3249
3136
  end
3250
3137
  end
3251
3138
  end
@@ -3283,15 +3170,15 @@ describe Mongoid::NestedAttributes do
3283
3170
  context "when reloading" do
3284
3171
 
3285
3172
  it "does not ignore the marked document" do
3286
- person.posts(true).find(post_one.id).title.should eq("Another Title")
3173
+ expect(person.posts(true).find(post_one.id).title).to eq("Another Title")
3287
3174
  end
3288
3175
 
3289
3176
  it "does not delete the unmarked document" do
3290
- person.posts(true).find(post_two.id).title.should eq("New Title")
3177
+ expect(person.posts(true).find(post_two.id).title).to eq("New Title")
3291
3178
  end
3292
3179
 
3293
3180
  it "does not add additional documents" do
3294
- person.posts(true).size.should eq(2)
3181
+ expect(person.posts(true).size).to eq(2)
3295
3182
  end
3296
3183
  end
3297
3184
  end
@@ -3312,11 +3199,11 @@ describe Mongoid::NestedAttributes do
3312
3199
  context "when reloading" do
3313
3200
 
3314
3201
  it "does not delete the marked document" do
3315
- person.posts(true).size.should eq(2)
3202
+ expect(person.posts(true).size).to eq(2)
3316
3203
  end
3317
3204
 
3318
3205
  it "does not delete the unmarked document" do
3319
- person.posts(true).last.title.should eq("New Title")
3206
+ expect(person.posts(true).last.title).to eq("New Title")
3320
3207
  end
3321
3208
  end
3322
3209
  end
@@ -3342,27 +3229,27 @@ describe Mongoid::NestedAttributes do
3342
3229
  end
3343
3230
 
3344
3231
  it "builds a new first document" do
3345
- person.posts.first.title.should eq("First")
3232
+ expect(person.posts.first.title).to eq("First")
3346
3233
  end
3347
3234
 
3348
3235
  it "builds a new second document" do
3349
- person.posts.second.title.should eq("Second")
3236
+ expect(person.posts.second.title).to eq("Second")
3350
3237
  end
3351
3238
 
3352
3239
  it "builds a new third document" do
3353
- person.posts.third.title.should eq("Third")
3240
+ expect(person.posts.third.title).to eq("Third")
3354
3241
  end
3355
3242
 
3356
3243
  it "does not add extra documents" do
3357
- person.posts.size.should eq(3)
3244
+ expect(person.posts.size).to eq(3)
3358
3245
  end
3359
3246
 
3360
3247
  it "does not persist the documents" do
3361
- person.posts.count.should eq(0)
3248
+ expect(person.posts.count).to eq(0)
3362
3249
  end
3363
3250
 
3364
3251
  it "adds the documents in the sorted hash key order" do
3365
- person.posts.map(&:title).should eq(
3252
+ expect(person.posts.map(&:title)).to eq(
3366
3253
  [ "First", "Second", "Third" ]
3367
3254
  )
3368
3255
  end
@@ -3383,23 +3270,23 @@ describe Mongoid::NestedAttributes do
3383
3270
  end
3384
3271
 
3385
3272
  it "builds a new first document" do
3386
- person.posts.first.title.should eq("Third")
3273
+ expect(person.posts.first.title).to eq("Third")
3387
3274
  end
3388
3275
 
3389
3276
  it "builds a new second document" do
3390
- person.posts.second.title.should eq("First")
3277
+ expect(person.posts.second.title).to eq("First")
3391
3278
  end
3392
3279
 
3393
3280
  it "builds a new third document" do
3394
- person.posts.third.title.should eq("Second")
3281
+ expect(person.posts.third.title).to eq("Second")
3395
3282
  end
3396
3283
 
3397
3284
  it "does not add extra documents" do
3398
- person.posts.size.should eq(3)
3285
+ expect(person.posts.size).to eq(3)
3399
3286
  end
3400
3287
 
3401
3288
  it "does not persist the documents" do
3402
- person.posts.count.should eq(0)
3289
+ expect(person.posts.count).to eq(0)
3403
3290
  end
3404
3291
  end
3405
3292
  end
@@ -3426,7 +3313,7 @@ describe Mongoid::NestedAttributes do
3426
3313
  end
3427
3314
 
3428
3315
  it "does not add the new document" do
3429
- person.posts.should be_empty
3316
+ expect(person.posts).to be_empty
3430
3317
  end
3431
3318
  end
3432
3319
 
@@ -3438,11 +3325,11 @@ describe Mongoid::NestedAttributes do
3438
3325
  end
3439
3326
 
3440
3327
  it "adds the new document" do
3441
- person.posts.size.should eq(1)
3328
+ expect(person.posts.size).to eq(1)
3442
3329
  end
3443
3330
 
3444
3331
  it "sets the correct attributes" do
3445
- person.posts.first.title.should eq("Blogging")
3332
+ expect(person.posts.first.title).to eq("Blogging")
3446
3333
  end
3447
3334
  end
3448
3335
  end
@@ -3468,7 +3355,7 @@ describe Mongoid::NestedAttributes do
3468
3355
  end
3469
3356
 
3470
3357
  it "does not add the new document" do
3471
- person.posts.should be_empty
3358
+ expect(person.posts).to be_empty
3472
3359
  end
3473
3360
  end
3474
3361
 
@@ -3480,11 +3367,11 @@ describe Mongoid::NestedAttributes do
3480
3367
  end
3481
3368
 
3482
3369
  it "adds the new document" do
3483
- person.posts.size.should eq(1)
3370
+ expect(person.posts.size).to eq(1)
3484
3371
  end
3485
3372
 
3486
3373
  it "sets the correct attributes" do
3487
- person.posts.first.title.should eq("Blogging")
3374
+ expect(person.posts.first.title).to eq("Blogging")
3488
3375
  end
3489
3376
  end
3490
3377
  end
@@ -3516,11 +3403,11 @@ describe Mongoid::NestedAttributes do
3516
3403
  end
3517
3404
 
3518
3405
  it "ignores the the marked document" do
3519
- person.posts.size.should eq(1)
3406
+ expect(person.posts.size).to eq(1)
3520
3407
  end
3521
3408
 
3522
3409
  it "adds the new unmarked document" do
3523
- person.posts.first.title.should eq("Blog Two")
3410
+ expect(person.posts.first.title).to eq("Blog Two")
3524
3411
  end
3525
3412
  end
3526
3413
  end
@@ -3538,15 +3425,15 @@ describe Mongoid::NestedAttributes do
3538
3425
  end
3539
3426
 
3540
3427
  it "adds the new marked document" do
3541
- person.posts.first.title.should eq("New Blog")
3428
+ expect(person.posts.first.title).to eq("New Blog")
3542
3429
  end
3543
3430
 
3544
3431
  it "adds the new unmarked document" do
3545
- person.posts.last.title.should eq("Blog Two")
3432
+ expect(person.posts.last.title).to eq("Blog Two")
3546
3433
  end
3547
3434
 
3548
3435
  it "does not add extra documents" do
3549
- person.posts.size.should eq(2)
3436
+ expect(person.posts.size).to eq(2)
3550
3437
  end
3551
3438
  end
3552
3439
  end
@@ -3577,15 +3464,15 @@ describe Mongoid::NestedAttributes do
3577
3464
  end
3578
3465
 
3579
3466
  it "adds the the marked document" do
3580
- person.posts.first.title.should eq("New Blog")
3467
+ expect(person.posts.first.title).to eq("New Blog")
3581
3468
  end
3582
3469
 
3583
3470
  it "adds the new unmarked document" do
3584
- person.posts.last.title.should eq("Blog Two")
3471
+ expect(person.posts.last.title).to eq("Blog Two")
3585
3472
  end
3586
3473
 
3587
3474
  it "adds the correct number of documents" do
3588
- person.posts.size.should eq(2)
3475
+ expect(person.posts.size).to eq(2)
3589
3476
  end
3590
3477
  end
3591
3478
  end
@@ -3603,15 +3490,15 @@ describe Mongoid::NestedAttributes do
3603
3490
  end
3604
3491
 
3605
3492
  it "adds the new marked document" do
3606
- person.posts.first.title.should eq("New Blog")
3493
+ expect(person.posts.first.title).to eq("New Blog")
3607
3494
  end
3608
3495
 
3609
3496
  it "adds the new unmarked document" do
3610
- person.posts.last.title.should eq("Blog Two")
3497
+ expect(person.posts.last.title).to eq("Blog Two")
3611
3498
  end
3612
3499
 
3613
3500
  it "does not add extra documents" do
3614
- person.posts.size.should eq(2)
3501
+ expect(person.posts.size).to eq(2)
3615
3502
  end
3616
3503
  end
3617
3504
  end
@@ -3637,15 +3524,15 @@ describe Mongoid::NestedAttributes do
3637
3524
  end
3638
3525
 
3639
3526
  it "adds the the marked document" do
3640
- person.posts.first.title.should eq("New Blog")
3527
+ expect(person.posts.first.title).to eq("New Blog")
3641
3528
  end
3642
3529
 
3643
3530
  it "adds the new unmarked document" do
3644
- person.posts.last.title.should eq("Blog Two")
3531
+ expect(person.posts.last.title).to eq("Blog Two")
3645
3532
  end
3646
3533
 
3647
3534
  it "adds the correct number of documents" do
3648
- person.posts.size.should eq(2)
3535
+ expect(person.posts.size).to eq(2)
3649
3536
  end
3650
3537
  end
3651
3538
  end
@@ -3663,15 +3550,15 @@ describe Mongoid::NestedAttributes do
3663
3550
  end
3664
3551
 
3665
3552
  it "adds the new marked document" do
3666
- person.posts.first.title.should eq("New Blog")
3553
+ expect(person.posts.first.title).to eq("New Blog")
3667
3554
  end
3668
3555
 
3669
3556
  it "adds the new unmarked document" do
3670
- person.posts.last.title.should eq("Blog Two")
3557
+ expect(person.posts.last.title).to eq("Blog Two")
3671
3558
  end
3672
3559
 
3673
3560
  it "does not add extra documents" do
3674
- person.posts.size.should eq(2)
3561
+ expect(person.posts.size).to eq(2)
3675
3562
  end
3676
3563
  end
3677
3564
  end
@@ -3696,8 +3583,8 @@ describe Mongoid::NestedAttributes do
3696
3583
  end
3697
3584
 
3698
3585
  it "propagates invalidity to parent" do
3699
- person.should_not be_valid
3700
- person.posts.first.should_not be_valid
3586
+ expect(person).to_not be_valid
3587
+ expect(person.posts.first).to_not be_valid
3701
3588
  end
3702
3589
  end
3703
3590
 
@@ -3718,7 +3605,7 @@ describe Mongoid::NestedAttributes do
3718
3605
  end
3719
3606
 
3720
3607
  it "instantiates an object of the given type" do
3721
- shipping_container.vehicles.map(&:class).should eq([Car, Truck])
3608
+ expect(shipping_container.vehicles.map(&:class)).to eq([Car, Truck])
3722
3609
  end
3723
3610
  end
3724
3611
  end
@@ -3780,7 +3667,7 @@ describe Mongoid::NestedAttributes do
3780
3667
  end
3781
3668
 
3782
3669
  it "sets the documents on the relation" do
3783
- person.preferences.size.should eq(2)
3670
+ expect(person.preferences.size).to eq(2)
3784
3671
  end
3785
3672
  end
3786
3673
  end
@@ -3810,15 +3697,15 @@ describe Mongoid::NestedAttributes do
3810
3697
  context "when reloading the document" do
3811
3698
 
3812
3699
  it "updates the first existing document" do
3813
- person.preferences(true).first.name.should eq("First")
3700
+ expect(person.preferences(true).first.name).to eq("First")
3814
3701
  end
3815
3702
 
3816
3703
  it "updates the second existing document" do
3817
- person.preferences(true).second.name.should eq("Second")
3704
+ expect(person.preferences(true).second.name).to eq("Second")
3818
3705
  end
3819
3706
 
3820
3707
  it "does not add new documents" do
3821
- person.preferences(true).size.should eq(2)
3708
+ expect(person.preferences(true).size).to eq(2)
3822
3709
  end
3823
3710
  end
3824
3711
  end
@@ -3865,11 +3752,11 @@ describe Mongoid::NestedAttributes do
3865
3752
  context "when reloading the documents" do
3866
3753
 
3867
3754
  it "deletes the marked document" do
3868
- person.preferences(true).size.should eq(1)
3755
+ expect(person.preferences(true).size).to eq(1)
3869
3756
  end
3870
3757
 
3871
3758
  it "does not delete the unmarked document" do
3872
- person.preferences(true).first.name.should eq("My Blog")
3759
+ expect(person.preferences(true).first.name).to eq("My Blog")
3873
3760
  end
3874
3761
  end
3875
3762
  end
@@ -3890,11 +3777,11 @@ describe Mongoid::NestedAttributes do
3890
3777
  context "when reloading the document" do
3891
3778
 
3892
3779
  it "does not delete the marked document" do
3893
- person.preferences(true).size.should eq(2)
3780
+ expect(person.preferences(true).size).to eq(2)
3894
3781
  end
3895
3782
 
3896
3783
  it "does not delete the unmarked document" do
3897
- person.preferences(true).last.name.should eq("My Blog")
3784
+ expect(person.preferences(true).last.name).to eq("My Blog")
3898
3785
  end
3899
3786
  end
3900
3787
  end
@@ -3929,15 +3816,15 @@ describe Mongoid::NestedAttributes do
3929
3816
  context "when reloading the document" do
3930
3817
 
3931
3818
  it "does not ignore the marked document" do
3932
- person.preferences(true).first.name.should eq("Another Title")
3819
+ expect(person.preferences(true).first.name).to eq("Another Title")
3933
3820
  end
3934
3821
 
3935
3822
  it "does not delete the unmarked document" do
3936
- person.preferences(true).last.name.should eq("New Title")
3823
+ expect(person.preferences(true).last.name).to eq("New Title")
3937
3824
  end
3938
3825
 
3939
3826
  it "does not add additional documents" do
3940
- person.preferences(true).size.should eq(2)
3827
+ expect(person.preferences(true).size).to eq(2)
3941
3828
  end
3942
3829
  end
3943
3830
  end
@@ -3958,11 +3845,11 @@ describe Mongoid::NestedAttributes do
3958
3845
  context "when reloading the documents" do
3959
3846
 
3960
3847
  it "does not delete the marked document" do
3961
- person.preferences(true).size.should eq(2)
3848
+ expect(person.preferences(true).size).to eq(2)
3962
3849
  end
3963
3850
 
3964
3851
  it "does not delete the unmarked document" do
3965
- person.preferences(true).last.name.should eq("New Title")
3852
+ expect(person.preferences(true).last.name).to eq("New Title")
3966
3853
  end
3967
3854
  end
3968
3855
  end
@@ -3992,15 +3879,15 @@ describe Mongoid::NestedAttributes do
3992
3879
  context "when reloading" do
3993
3880
 
3994
3881
  it "does not ignore the marked document" do
3995
- person.preferences(true).first.name.should eq("Another Title")
3882
+ expect(person.preferences(true).first.name).to eq("Another Title")
3996
3883
  end
3997
3884
 
3998
3885
  it "does not delete the unmarked document" do
3999
- person.preferences(true).last.name.should eq("New Title")
3886
+ expect(person.preferences(true).last.name).to eq("New Title")
4000
3887
  end
4001
3888
 
4002
3889
  it "does not add additional documents" do
4003
- person.preferences(true).size.should eq(2)
3890
+ expect(person.preferences(true).size).to eq(2)
4004
3891
  end
4005
3892
  end
4006
3893
  end
@@ -4021,11 +3908,11 @@ describe Mongoid::NestedAttributes do
4021
3908
  context "when reloading" do
4022
3909
 
4023
3910
  it "does not delete the marked document" do
4024
- person.preferences(true).size.should eq(2)
3911
+ expect(person.preferences(true).size).to eq(2)
4025
3912
  end
4026
3913
 
4027
3914
  it "does not delete the unmarked document" do
4028
- person.preferences(true).last.name.should eq("New Title")
3915
+ expect(person.preferences(true).last.name).to eq("New Title")
4029
3916
  end
4030
3917
  end
4031
3918
  end
@@ -4049,23 +3936,23 @@ describe Mongoid::NestedAttributes do
4049
3936
  end
4050
3937
 
4051
3938
  it "builds a new first document" do
4052
- person.preferences.first.name.should eq("First")
3939
+ expect(person.preferences.first.name).to eq("First")
4053
3940
  end
4054
3941
 
4055
3942
  it "builds a new second document" do
4056
- person.preferences.second.name.should eq("Second")
3943
+ expect(person.preferences.second.name).to eq("Second")
4057
3944
  end
4058
3945
 
4059
3946
  it "builds a new third document" do
4060
- person.preferences.third.name.should eq("Third")
3947
+ expect(person.preferences.third.name).to eq("Third")
4061
3948
  end
4062
3949
 
4063
3950
  it "does not add extra documents" do
4064
- person.preferences.size.should eq(3)
3951
+ expect(person.preferences.size).to eq(3)
4065
3952
  end
4066
3953
 
4067
3954
  it "adds the documents in the sorted hash key order" do
4068
- person.preferences.map(&:name).should eq(
3955
+ expect(person.preferences.map(&:name)).to eq(
4069
3956
  [ "First", "Second", "Third" ]
4070
3957
  )
4071
3958
  end
@@ -4092,7 +3979,7 @@ describe Mongoid::NestedAttributes do
4092
3979
  end
4093
3980
 
4094
3981
  it "does not add the new document" do
4095
- person.preferences.should be_empty
3982
+ expect(person.preferences).to be_empty
4096
3983
  end
4097
3984
  end
4098
3985
 
@@ -4104,11 +3991,11 @@ describe Mongoid::NestedAttributes do
4104
3991
  end
4105
3992
 
4106
3993
  it "adds the new document" do
4107
- person.preferences.size.should eq(1)
3994
+ expect(person.preferences.size).to eq(1)
4108
3995
  end
4109
3996
 
4110
3997
  it "sets the correct attributes" do
4111
- person.preferences.first.name.should eq("Blogging")
3998
+ expect(person.preferences.first.name).to eq("Blogging")
4112
3999
  end
4113
4000
  end
4114
4001
  end
@@ -4134,7 +4021,7 @@ describe Mongoid::NestedAttributes do
4134
4021
  end
4135
4022
 
4136
4023
  it "does not add the new document" do
4137
- person.preferences.should be_empty
4024
+ expect(person.preferences).to be_empty
4138
4025
  end
4139
4026
  end
4140
4027
 
@@ -4146,11 +4033,11 @@ describe Mongoid::NestedAttributes do
4146
4033
  end
4147
4034
 
4148
4035
  it "adds the new document" do
4149
- person.preferences.size.should eq(1)
4036
+ expect(person.preferences.size).to eq(1)
4150
4037
  end
4151
4038
 
4152
4039
  it "sets the correct attributes" do
4153
- person.preferences.first.name.should eq("Blogging")
4040
+ expect(person.preferences.first.name).to eq("Blogging")
4154
4041
  end
4155
4042
  end
4156
4043
  end
@@ -4182,11 +4069,11 @@ describe Mongoid::NestedAttributes do
4182
4069
  end
4183
4070
 
4184
4071
  it "ignores the the marked document" do
4185
- person.preferences.size.should eq(1)
4072
+ expect(person.preferences.size).to eq(1)
4186
4073
  end
4187
4074
 
4188
4075
  it "adds the new unmarked document" do
4189
- person.preferences.first.name.should eq("Blog Two")
4076
+ expect(person.preferences.first.name).to eq("Blog Two")
4190
4077
  end
4191
4078
  end
4192
4079
  end
@@ -4204,15 +4091,15 @@ describe Mongoid::NestedAttributes do
4204
4091
  end
4205
4092
 
4206
4093
  it "adds the new marked document" do
4207
- person.preferences.first.name.should eq("New Blog")
4094
+ expect(person.preferences.first.name).to eq("New Blog")
4208
4095
  end
4209
4096
 
4210
4097
  it "adds the new unmarked document" do
4211
- person.preferences.last.name.should eq("Blog Two")
4098
+ expect(person.preferences.last.name).to eq("Blog Two")
4212
4099
  end
4213
4100
 
4214
4101
  it "does not add extra documents" do
4215
- person.preferences.size.should eq(2)
4102
+ expect(person.preferences.size).to eq(2)
4216
4103
  end
4217
4104
  end
4218
4105
  end
@@ -4243,15 +4130,15 @@ describe Mongoid::NestedAttributes do
4243
4130
  end
4244
4131
 
4245
4132
  it "adds the the marked document" do
4246
- person.preferences.first.name.should eq("New Blog")
4133
+ expect(person.preferences.first.name).to eq("New Blog")
4247
4134
  end
4248
4135
 
4249
4136
  it "adds the new unmarked document" do
4250
- person.preferences.last.name.should eq("Blog Two")
4137
+ expect(person.preferences.last.name).to eq("Blog Two")
4251
4138
  end
4252
4139
 
4253
4140
  it "adds the correct number of documents" do
4254
- person.preferences.size.should eq(2)
4141
+ expect(person.preferences.size).to eq(2)
4255
4142
  end
4256
4143
  end
4257
4144
  end
@@ -4269,15 +4156,15 @@ describe Mongoid::NestedAttributes do
4269
4156
  end
4270
4157
 
4271
4158
  it "adds the new marked document" do
4272
- person.preferences.first.name.should eq("New Blog")
4159
+ expect(person.preferences.first.name).to eq("New Blog")
4273
4160
  end
4274
4161
 
4275
4162
  it "adds the new unmarked document" do
4276
- person.preferences.last.name.should eq("Blog Two")
4163
+ expect(person.preferences.last.name).to eq("Blog Two")
4277
4164
  end
4278
4165
 
4279
4166
  it "does not add extra documents" do
4280
- person.preferences.size.should eq(2)
4167
+ expect(person.preferences.size).to eq(2)
4281
4168
  end
4282
4169
  end
4283
4170
  end
@@ -4303,15 +4190,15 @@ describe Mongoid::NestedAttributes do
4303
4190
  end
4304
4191
 
4305
4192
  it "adds the the marked document" do
4306
- person.preferences.first.name.should eq("New Blog")
4193
+ expect(person.preferences.first.name).to eq("New Blog")
4307
4194
  end
4308
4195
 
4309
4196
  it "adds the new unmarked document" do
4310
- person.preferences.last.name.should eq("Blog Two")
4197
+ expect(person.preferences.last.name).to eq("Blog Two")
4311
4198
  end
4312
4199
 
4313
4200
  it "adds the correct number of documents" do
4314
- person.preferences.size.should eq(2)
4201
+ expect(person.preferences.size).to eq(2)
4315
4202
  end
4316
4203
  end
4317
4204
  end
@@ -4329,15 +4216,15 @@ describe Mongoid::NestedAttributes do
4329
4216
  end
4330
4217
 
4331
4218
  it "adds the new marked document" do
4332
- person.preferences.first.name.should eq("New Blog")
4219
+ expect(person.preferences.first.name).to eq("New Blog")
4333
4220
  end
4334
4221
 
4335
4222
  it "adds the new unmarked document" do
4336
- person.preferences.last.name.should eq("Blog Two")
4223
+ expect(person.preferences.last.name).to eq("Blog Two")
4337
4224
  end
4338
4225
 
4339
4226
  it "does not add extra documents" do
4340
- person.preferences.size.should eq(2)
4227
+ expect(person.preferences.size).to eq(2)
4341
4228
  end
4342
4229
  end
4343
4230
  end
@@ -4362,8 +4249,8 @@ describe Mongoid::NestedAttributes do
4362
4249
  end
4363
4250
 
4364
4251
  it "propagates invalidity to parent" do
4365
- person.preferences.first.should_not be_valid
4366
- person.should_not be_valid
4252
+ expect(person.preferences.first).to_not be_valid
4253
+ expect(person).to_not be_valid
4367
4254
  end
4368
4255
  end
4369
4256
  end
@@ -4407,11 +4294,11 @@ describe Mongoid::NestedAttributes do
4407
4294
  end
4408
4295
 
4409
4296
  it "adds the new embedded document" do
4410
- server.reload.filesystems.first.name.should eq("NFS")
4297
+ expect(server.reload.filesystems.first.name).to eq("NFS")
4411
4298
  end
4412
4299
 
4413
4300
  it "does not add more than one document" do
4414
- server.reload.filesystems.count.should eq(1)
4301
+ expect(server.reload.filesystems.count).to eq(1)
4415
4302
  end
4416
4303
  end
4417
4304
  end
@@ -4439,23 +4326,23 @@ describe Mongoid::NestedAttributes do
4439
4326
  end
4440
4327
 
4441
4328
  it "removes the document from the parent" do
4442
- person.services.should be_empty
4329
+ expect(person.services).to be_empty
4443
4330
  end
4444
4331
 
4445
4332
  it "deletes the document" do
4446
- service.should be_destroyed
4333
+ expect(service).to be_destroyed
4447
4334
  end
4448
4335
 
4449
4336
  it "runs the before destroy callbacks" do
4450
- service.before_destroy_called.should be_true
4337
+ expect(service.before_destroy_called).to be true
4451
4338
  end
4452
4339
 
4453
4340
  it "runs the after destroy callbacks" do
4454
- service.after_destroy_called.should be_true
4341
+ expect(service.after_destroy_called).to be true
4455
4342
  end
4456
4343
 
4457
4344
  it "clears the delayed atomic pulls from the parent" do
4458
- person.delayed_atomic_pulls.should be_empty
4345
+ expect(person.delayed_atomic_pulls).to be_empty
4459
4346
  end
4460
4347
  end
4461
4348
 
@@ -4494,12 +4381,12 @@ describe Mongoid::NestedAttributes do
4494
4381
  end
4495
4382
 
4496
4383
  before do
4497
- address.with(safe: true).update_attributes(attributes)
4384
+ address.update_attributes(attributes)
4498
4385
  address.reload
4499
4386
  end
4500
4387
 
4501
4388
  it "does not add any extra locations" do
4502
- address.locations.size.should eq(2)
4389
+ expect(address.locations.size).to eq(2)
4503
4390
  end
4504
4391
  end
4505
4392
 
@@ -4541,11 +4428,11 @@ describe Mongoid::NestedAttributes do
4541
4428
  end
4542
4429
 
4543
4430
  it "deletes the document from the relation" do
4544
- address_one.locations.should be_empty
4431
+ expect(address_one.locations).to be_empty
4545
4432
  end
4546
4433
 
4547
4434
  it "persists the change" do
4548
- address_one.reload.locations.should be_empty
4435
+ expect(address_one.reload.locations).to be_empty
4549
4436
  end
4550
4437
  end
4551
4438
 
@@ -4591,15 +4478,15 @@ describe Mongoid::NestedAttributes do
4591
4478
  end
4592
4479
 
4593
4480
  it "removes the child from the relation" do
4594
- record.tracks.should be_empty
4481
+ expect(record.tracks).to be_empty
4595
4482
  end
4596
4483
 
4597
4484
  it "deletes the child document" do
4598
- track.should be_destroyed
4485
+ expect(track).to be_destroyed
4599
4486
  end
4600
4487
 
4601
4488
  it "runs the child's callbacks" do
4602
- track.before_destroy_called.should be_true
4489
+ expect(track.before_destroy_called).to be true
4603
4490
  end
4604
4491
  end
4605
4492
  end
@@ -4620,7 +4507,7 @@ describe Mongoid::NestedAttributes do
4620
4507
  end
4621
4508
 
4622
4509
  before do
4623
- person.with(safe: true).update_attributes(attributes)
4510
+ person.update_attributes(attributes)
4624
4511
  end
4625
4512
 
4626
4513
  let(:address) do
@@ -4632,11 +4519,11 @@ describe Mongoid::NestedAttributes do
4632
4519
  end
4633
4520
 
4634
4521
  it "adds the new first level embedded document" do
4635
- address.street.should eq("Alexanderstr")
4522
+ expect(address.street).to eq("Alexanderstr")
4636
4523
  end
4637
4524
 
4638
4525
  it "adds the nested embedded document" do
4639
- location.name.should eq("Home")
4526
+ expect(location.name).to eq("Home")
4640
4527
  end
4641
4528
  end
4642
4529
 
@@ -4660,16 +4547,16 @@ describe Mongoid::NestedAttributes do
4660
4547
  end
4661
4548
 
4662
4549
  before do
4663
- person.with(safe: true).update_attributes(attributes)
4550
+ person.update_attributes(attributes)
4664
4551
  person.reload
4665
4552
  end
4666
4553
 
4667
4554
  it "adds the new location to the existing address" do
4668
- person.addresses.first.locations.count.should eq(2)
4555
+ expect(person.addresses.first.locations.count).to eq(2)
4669
4556
  end
4670
4557
 
4671
4558
  it "adds the new address" do
4672
- person.addresses.count.should eq(2)
4559
+ expect(person.addresses.count).to eq(2)
4673
4560
  end
4674
4561
  end
4675
4562
  end
@@ -4691,7 +4578,7 @@ describe Mongoid::NestedAttributes do
4691
4578
  end
4692
4579
 
4693
4580
  before do
4694
- person.with(safe: true).update_attributes(attributes)
4581
+ person.update_attributes(attributes)
4695
4582
  end
4696
4583
 
4697
4584
  let(:address) do
@@ -4703,11 +4590,11 @@ describe Mongoid::NestedAttributes do
4703
4590
  end
4704
4591
 
4705
4592
  it "adds the new first level embedded document" do
4706
- address.street.should eq("Alexanderstr")
4593
+ expect(address.street).to eq("Alexanderstr")
4707
4594
  end
4708
4595
 
4709
4596
  it "adds the nested embedded document" do
4710
- code.name.should eq("Home")
4597
+ expect(code.name).to eq("Home")
4711
4598
  end
4712
4599
  end
4713
4600
  end
@@ -4740,15 +4627,15 @@ describe Mongoid::NestedAttributes do
4740
4627
  end
4741
4628
 
4742
4629
  before do
4743
- person.with(safe: true).update_attributes(attributes)
4630
+ person.update_attributes(attributes)
4744
4631
  end
4745
4632
 
4746
4633
  it "updates the first level embedded document" do
4747
- address.number.should eq(45)
4634
+ expect(address.number).to eq(45)
4748
4635
  end
4749
4636
 
4750
4637
  it "updates the nested embedded document" do
4751
- code.name.should eq("Work")
4638
+ expect(code.name).to eq("Work")
4752
4639
  end
4753
4640
  end
4754
4641
 
@@ -4780,15 +4667,15 @@ describe Mongoid::NestedAttributes do
4780
4667
  end
4781
4668
 
4782
4669
  before do
4783
- person.with(safe: true).update_attributes(attributes)
4670
+ person.update_attributes(attributes)
4784
4671
  end
4785
4672
 
4786
4673
  it "updates the first level embedded document" do
4787
- address.number.should eq(45)
4674
+ expect(address.number).to eq(45)
4788
4675
  end
4789
4676
 
4790
4677
  it "updates the nested embedded document" do
4791
- target.name.should eq("updated")
4678
+ expect(target.name).to eq("updated")
4792
4679
  end
4793
4680
  end
4794
4681
 
@@ -4816,11 +4703,11 @@ describe Mongoid::NestedAttributes do
4816
4703
  end
4817
4704
 
4818
4705
  before do
4819
- person.with(safe: true).update_attributes(attributes)
4706
+ person.update_attributes(attributes)
4820
4707
  end
4821
4708
 
4822
4709
  it "updates the nested embedded document" do
4823
- language.name.should eq("deutsch")
4710
+ expect(language.name).to eq("deutsch")
4824
4711
  end
4825
4712
  end
4826
4713
  end
@@ -4851,11 +4738,11 @@ describe Mongoid::NestedAttributes do
4851
4738
  end
4852
4739
 
4853
4740
  it "adds the new document to the relation" do
4854
- post.title.should eq("Testing")
4741
+ expect(post.title).to eq("Testing")
4855
4742
  end
4856
4743
 
4857
4744
  it "autosaves the relation" do
4858
- user.posts(true).first.title.should eq("Testing")
4745
+ expect(user.posts(true).first.title).to eq("Testing")
4859
4746
  end
4860
4747
  end
4861
4748
 
@@ -4882,15 +4769,15 @@ describe Mongoid::NestedAttributes do
4882
4769
  end
4883
4770
 
4884
4771
  it "returns false" do
4885
- update.should be_false
4772
+ expect(update).to be false
4886
4773
  end
4887
4774
 
4888
4775
  it "does not update the child document" do
4889
- server.reload.name.should eq("test")
4776
+ expect(server.reload.name).to eq("test")
4890
4777
  end
4891
4778
 
4892
4779
  it "adds the errors to the document" do
4893
- node.errors[:servers].should_not be_nil
4780
+ expect(node.errors[:servers]).to_not be_nil
4894
4781
  end
4895
4782
  end
4896
4783
  end
@@ -4917,7 +4804,7 @@ describe Mongoid::NestedAttributes do
4917
4804
  end
4918
4805
 
4919
4806
  it "sets the nested attributes" do
4920
- league.reload.divisions.first.name.should eq("New Name")
4807
+ expect(league.reload.divisions.first.name).to eq("New Name")
4921
4808
  end
4922
4809
 
4923
4810
  context "with corrupted data" do
@@ -4937,7 +4824,7 @@ describe Mongoid::NestedAttributes do
4937
4824
  end
4938
4825
 
4939
4826
  it "sets the nested attributes" do
4940
- league.reload.divisions.first.name.should eq("Name")
4827
+ expect(league.reload.divisions.first.name).to eq("Name")
4941
4828
  end
4942
4829
  end
4943
4830
  end