shoulda-matchers 3.1.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (288) hide show
  1. checksums.yaml +5 -5
  2. data/{MIT-LICENSE → LICENSE} +1 -1
  3. data/README.md +407 -232
  4. data/docs/errors/NonCaseSwappableValueError.md +2 -2
  5. data/lib/shoulda/matchers/action_controller/callback_matcher.rb +7 -80
  6. data/lib/shoulda/matchers/action_controller/filter_param_matcher.rb +4 -3
  7. data/lib/shoulda/matchers/action_controller/flash_store.rb +2 -4
  8. data/lib/shoulda/matchers/action_controller/permit_matcher.rb +36 -30
  9. data/lib/shoulda/matchers/action_controller/redirect_to_matcher.rb +8 -10
  10. data/lib/shoulda/matchers/action_controller/render_template_matcher.rb +7 -9
  11. data/lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb +18 -15
  12. data/lib/shoulda/matchers/action_controller/rescue_from_matcher.rb +3 -2
  13. data/lib/shoulda/matchers/action_controller/respond_with_matcher.rb +3 -3
  14. data/lib/shoulda/matchers/action_controller/route_matcher.rb +88 -29
  15. data/lib/shoulda/matchers/action_controller/route_params.rb +2 -2
  16. data/lib/shoulda/matchers/action_controller/set_flash_matcher.rb +4 -4
  17. data/lib/shoulda/matchers/action_controller/set_session_matcher.rb +3 -3
  18. data/lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb +19 -13
  19. data/lib/shoulda/matchers/action_controller.rb +2 -0
  20. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_changed_value_error.rb +1 -1
  21. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setter.rb +5 -9
  22. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setter_and_validator.rb +2 -2
  23. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb +1 -1
  24. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators.rb +1 -1
  25. data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +42 -39
  26. data/lib/shoulda/matchers/active_model/disallow_value_matcher.rb +1 -1
  27. data/lib/shoulda/matchers/active_model/have_secure_password_matcher.rb +52 -26
  28. data/lib/shoulda/matchers/active_model/helpers.rb +2 -2
  29. data/lib/shoulda/matchers/active_model/numericality_matchers/comparison_matcher.rb +32 -30
  30. data/lib/shoulda/matchers/active_model/numericality_matchers/numeric_type_matcher.rb +2 -1
  31. data/lib/shoulda/matchers/active_model/qualifiers/allow_blank.rb +26 -0
  32. data/lib/shoulda/matchers/active_model/qualifiers/allow_nil.rb +26 -0
  33. data/lib/shoulda/matchers/active_model/qualifiers/ignoring_interference_by_writer.rb +1 -1
  34. data/lib/shoulda/matchers/active_model/qualifiers.rb +2 -0
  35. data/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +30 -6
  36. data/lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb +8 -3
  37. data/lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb +31 -16
  38. data/lib/shoulda/matchers/active_model/validate_exclusion_of_matcher.rb +52 -16
  39. data/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +137 -84
  40. data/lib/shoulda/matchers/active_model/validate_length_of_matcher.rb +159 -46
  41. data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +130 -66
  42. data/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb +251 -24
  43. data/lib/shoulda/matchers/active_model/validation_matcher/build_description.rb +12 -9
  44. data/lib/shoulda/matchers/active_model/validation_matcher.rb +38 -6
  45. data/lib/shoulda/matchers/active_model/validation_message_finder.rb +2 -4
  46. data/lib/shoulda/matchers/active_model/validator.rb +4 -9
  47. data/lib/shoulda/matchers/active_model.rb +3 -5
  48. data/lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb +10 -7
  49. data/lib/shoulda/matchers/active_record/association_matcher.rb +386 -111
  50. data/lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb +5 -2
  51. data/lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb +4 -4
  52. data/lib/shoulda/matchers/active_record/association_matchers/inverse_of_matcher.rb +1 -1
  53. data/lib/shoulda/matchers/active_record/association_matchers/join_table_matcher.rb +11 -6
  54. data/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +14 -15
  55. data/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +30 -8
  56. data/lib/shoulda/matchers/active_record/association_matchers/option_verifier.rb +34 -11
  57. data/lib/shoulda/matchers/active_record/association_matchers/optional_matcher.rb +69 -0
  58. data/lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb +1 -1
  59. data/lib/shoulda/matchers/active_record/association_matchers/required_matcher.rb +74 -0
  60. data/lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb +3 -2
  61. data/lib/shoulda/matchers/active_record/association_matchers/through_matcher.rb +7 -5
  62. data/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb +458 -42
  63. data/lib/shoulda/matchers/active_record/have_attached_matcher.rb +185 -0
  64. data/lib/shoulda/matchers/active_record/have_db_column_matcher.rb +63 -23
  65. data/lib/shoulda/matchers/active_record/have_db_index_matcher.rb +164 -48
  66. data/lib/shoulda/matchers/active_record/have_implicit_order_column.rb +106 -0
  67. data/lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb +13 -11
  68. data/lib/shoulda/matchers/active_record/have_rich_text_matcher.rb +83 -0
  69. data/lib/shoulda/matchers/active_record/have_secure_token_matcher.rb +132 -0
  70. data/lib/shoulda/matchers/active_record/serialize_matcher.rb +18 -18
  71. data/lib/shoulda/matchers/active_record/uniqueness/test_model_creator.rb +1 -3
  72. data/lib/shoulda/matchers/active_record/uniqueness/test_models.rb +0 -2
  73. data/lib/shoulda/matchers/active_record/uniqueness.rb +1 -1
  74. data/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +430 -200
  75. data/lib/shoulda/matchers/active_record.rb +28 -20
  76. data/lib/shoulda/matchers/configuration.rb +12 -1
  77. data/lib/shoulda/matchers/doublespeak/double.rb +1 -1
  78. data/lib/shoulda/matchers/doublespeak/double_collection.rb +3 -3
  79. data/lib/shoulda/matchers/doublespeak/double_implementation_registry.rb +8 -5
  80. data/lib/shoulda/matchers/doublespeak/object_double.rb +6 -2
  81. data/lib/shoulda/matchers/doublespeak/stub_implementation.rb +1 -5
  82. data/lib/shoulda/matchers/doublespeak/world.rb +2 -2
  83. data/lib/shoulda/matchers/doublespeak.rb +2 -1
  84. data/lib/shoulda/matchers/error.rb +1 -1
  85. data/lib/shoulda/matchers/independent/delegate_method_matcher.rb +109 -29
  86. data/lib/shoulda/matchers/independent.rb +2 -2
  87. data/lib/shoulda/matchers/integrations/configuration.rb +8 -4
  88. data/lib/shoulda/matchers/integrations/libraries/action_controller.rb +1 -1
  89. data/lib/shoulda/matchers/integrations/libraries/rails.rb +2 -2
  90. data/lib/shoulda/matchers/integrations/test_frameworks/active_support_test_case.rb +1 -1
  91. data/lib/shoulda/matchers/integrations/test_frameworks/minitest_4.rb +1 -1
  92. data/lib/shoulda/matchers/integrations/test_frameworks/minitest_5.rb +1 -1
  93. data/lib/shoulda/matchers/integrations/test_frameworks/missing_test_framework.rb +1 -1
  94. data/lib/shoulda/matchers/integrations/test_frameworks/test_unit.rb +1 -1
  95. data/lib/shoulda/matchers/rails_shim.rb +172 -51
  96. data/lib/shoulda/matchers/routing.rb +2 -2
  97. data/lib/shoulda/matchers/util/word_wrap.rb +17 -12
  98. data/lib/shoulda/matchers/util.rb +39 -5
  99. data/lib/shoulda/matchers/version.rb +1 -1
  100. data/lib/shoulda/matchers/warn.rb +4 -3
  101. data/shoulda-matchers.gemspec +33 -15
  102. metadata +31 -338
  103. data/.gitignore +0 -12
  104. data/.hound.yml +0 -3
  105. data/.hound_config/ruby.yml +0 -12
  106. data/.travis.yml +0 -19
  107. data/.yardopts +0 -10
  108. data/Appraisals +0 -73
  109. data/CONTRIBUTING.md +0 -101
  110. data/Gemfile +0 -15
  111. data/Gemfile.lock +0 -70
  112. data/NEWS.md +0 -986
  113. data/Rakefile +0 -39
  114. data/custom_plan.rb +0 -88
  115. data/doc_config/gh-pages/index.html.erb +0 -9
  116. data/doc_config/yard/setup.rb +0 -22
  117. data/doc_config/yard/templates/default/fulldoc/html/css/bootstrap.css +0 -5967
  118. data/doc_config/yard/templates/default/fulldoc/html/css/full_list.css +0 -12
  119. data/doc_config/yard/templates/default/fulldoc/html/css/global.css +0 -62
  120. data/doc_config/yard/templates/default/fulldoc/html/css/solarized.css +0 -69
  121. data/doc_config/yard/templates/default/fulldoc/html/css/style.css +0 -312
  122. data/doc_config/yard/templates/default/fulldoc/html/full_list.erb +0 -32
  123. data/doc_config/yard/templates/default/fulldoc/html/full_list_class.erb +0 -1
  124. data/doc_config/yard/templates/default/fulldoc/html/full_list_method.erb +0 -8
  125. data/doc_config/yard/templates/default/fulldoc/html/js/app.js +0 -298
  126. data/doc_config/yard/templates/default/fulldoc/html/js/full_list.js +0 -1
  127. data/doc_config/yard/templates/default/fulldoc/html/js/jquery.stickyheaders.js +0 -289
  128. data/doc_config/yard/templates/default/fulldoc/html/js/underscore.min.js +0 -6
  129. data/doc_config/yard/templates/default/fulldoc/html/setup.rb +0 -8
  130. data/doc_config/yard/templates/default/layout/html/breadcrumb.erb +0 -14
  131. data/doc_config/yard/templates/default/layout/html/fonts.erb +0 -1
  132. data/doc_config/yard/templates/default/layout/html/footer.erb +0 -6
  133. data/doc_config/yard/templates/default/layout/html/layout.erb +0 -23
  134. data/doc_config/yard/templates/default/layout/html/search.erb +0 -13
  135. data/doc_config/yard/templates/default/layout/html/setup.rb +0 -40
  136. data/doc_config/yard/templates/default/method_details/html/source.erb +0 -10
  137. data/doc_config/yard/templates/default/module/html/box_info.erb +0 -31
  138. data/gemfiles/4.0.0.gemfile +0 -38
  139. data/gemfiles/4.0.0.gemfile.lock +0 -223
  140. data/gemfiles/4.0.1.gemfile +0 -38
  141. data/gemfiles/4.0.1.gemfile.lock +0 -225
  142. data/gemfiles/4.1.gemfile +0 -38
  143. data/gemfiles/4.1.gemfile.lock +0 -220
  144. data/gemfiles/4.2.gemfile +0 -38
  145. data/gemfiles/4.2.gemfile.lock +0 -243
  146. data/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb +0 -159
  147. data/lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb +0 -37
  148. data/script/SUPPORTED_VERSIONS +0 -1
  149. data/script/install_gems_in_all_appraisals +0 -14
  150. data/script/run_all_tests +0 -14
  151. data/script/update_gem_in_all_appraisals +0 -15
  152. data/script/update_gems_in_all_appraisals +0 -14
  153. data/spec/acceptance/active_model_integration_spec.rb +0 -23
  154. data/spec/acceptance/independent_matchers_spec.rb +0 -125
  155. data/spec/acceptance/multiple_libraries_integration_spec.rb +0 -55
  156. data/spec/acceptance/rails_integration_spec.rb +0 -156
  157. data/spec/acceptance_spec_helper.rb +0 -23
  158. data/spec/doublespeak_spec_helper.rb +0 -2
  159. data/spec/report_warnings.rb +0 -7
  160. data/spec/spec_helper.rb +0 -21
  161. data/spec/support/acceptance/adds_shoulda_matchers_to_project.rb +0 -133
  162. data/spec/support/acceptance/helpers/active_model_helpers.rb +0 -11
  163. data/spec/support/acceptance/helpers/array_helpers.rb +0 -13
  164. data/spec/support/acceptance/helpers/base_helpers.rb +0 -19
  165. data/spec/support/acceptance/helpers/command_helpers.rb +0 -55
  166. data/spec/support/acceptance/helpers/file_helpers.rb +0 -19
  167. data/spec/support/acceptance/helpers/gem_helpers.rb +0 -31
  168. data/spec/support/acceptance/helpers/minitest_helpers.rb +0 -11
  169. data/spec/support/acceptance/helpers/n_unit_helpers.rb +0 -25
  170. data/spec/support/acceptance/helpers/pluralization_helpers.rb +0 -13
  171. data/spec/support/acceptance/helpers/rails_version_helpers.rb +0 -11
  172. data/spec/support/acceptance/helpers/rspec_helpers.rb +0 -24
  173. data/spec/support/acceptance/helpers/ruby_version_helpers.rb +0 -9
  174. data/spec/support/acceptance/helpers/step_helpers.rb +0 -127
  175. data/spec/support/acceptance/helpers.rb +0 -31
  176. data/spec/support/acceptance/matchers/have_output.rb +0 -31
  177. data/spec/support/acceptance/matchers/indicate_number_of_tests_was_run_matcher.rb +0 -55
  178. data/spec/support/acceptance/matchers/indicate_that_tests_were_run_matcher.rb +0 -103
  179. data/spec/support/tests/bundle.rb +0 -94
  180. data/spec/support/tests/command_runner.rb +0 -230
  181. data/spec/support/tests/current_bundle.rb +0 -61
  182. data/spec/support/tests/database.rb +0 -28
  183. data/spec/support/tests/database_adapters/postgresql.rb +0 -25
  184. data/spec/support/tests/database_adapters/sqlite3.rb +0 -26
  185. data/spec/support/tests/database_configuration.rb +0 -33
  186. data/spec/support/tests/database_configuration_registry.rb +0 -28
  187. data/spec/support/tests/filesystem.rb +0 -100
  188. data/spec/support/tests/version.rb +0 -45
  189. data/spec/support/unit/active_record/create_table.rb +0 -54
  190. data/spec/support/unit/attribute.rb +0 -47
  191. data/spec/support/unit/capture.rb +0 -40
  192. data/spec/support/unit/change_value.rb +0 -111
  193. data/spec/support/unit/create_model_arguments/basic.rb +0 -135
  194. data/spec/support/unit/create_model_arguments/has_many.rb +0 -15
  195. data/spec/support/unit/create_model_arguments/uniqueness_matcher.rb +0 -74
  196. data/spec/support/unit/helpers/active_model_helpers.rb +0 -27
  197. data/spec/support/unit/helpers/active_model_versions.rb +0 -28
  198. data/spec/support/unit/helpers/active_record_versions.rb +0 -24
  199. data/spec/support/unit/helpers/active_resource_builder.rb +0 -27
  200. data/spec/support/unit/helpers/allow_value_matcher_helpers.rb +0 -15
  201. data/spec/support/unit/helpers/class_builder.rb +0 -90
  202. data/spec/support/unit/helpers/column_type_helpers.rb +0 -26
  203. data/spec/support/unit/helpers/confirmation_matcher_helpers.rb +0 -17
  204. data/spec/support/unit/helpers/controller_builder.rb +0 -63
  205. data/spec/support/unit/helpers/database_helpers.rb +0 -20
  206. data/spec/support/unit/helpers/i18n_faker.rb +0 -15
  207. data/spec/support/unit/helpers/mailer_builder.rb +0 -12
  208. data/spec/support/unit/helpers/model_builder.rb +0 -114
  209. data/spec/support/unit/helpers/rails_versions.rb +0 -28
  210. data/spec/support/unit/helpers/validation_matcher_scenario_helpers.rb +0 -44
  211. data/spec/support/unit/i18n.rb +0 -7
  212. data/spec/support/unit/load_environment.rb +0 -12
  213. data/spec/support/unit/matchers/deprecate.rb +0 -60
  214. data/spec/support/unit/matchers/fail_with_message_including_matcher.rb +0 -51
  215. data/spec/support/unit/matchers/fail_with_message_matcher.rb +0 -62
  216. data/spec/support/unit/matchers/print_warning_including.rb +0 -59
  217. data/spec/support/unit/model_creation_strategies/active_model.rb +0 -111
  218. data/spec/support/unit/model_creation_strategies/active_record.rb +0 -77
  219. data/spec/support/unit/model_creators/active_model.rb +0 -39
  220. data/spec/support/unit/model_creators/active_record/has_and_belongs_to_many.rb +0 -95
  221. data/spec/support/unit/model_creators/active_record/has_many.rb +0 -67
  222. data/spec/support/unit/model_creators/active_record/uniqueness_matcher.rb +0 -42
  223. data/spec/support/unit/model_creators/active_record.rb +0 -43
  224. data/spec/support/unit/model_creators/basic.rb +0 -97
  225. data/spec/support/unit/model_creators.rb +0 -19
  226. data/spec/support/unit/rails_application.rb +0 -126
  227. data/spec/support/unit/record_builder_with_i18n_validation_message.rb +0 -69
  228. data/spec/support/unit/record_validating_confirmation_builder.rb +0 -51
  229. data/spec/support/unit/record_with_different_error_attribute_builder.rb +0 -92
  230. data/spec/support/unit/shared_examples/ignoring_interference_by_writer.rb +0 -79
  231. data/spec/support/unit/shared_examples/numerical_submatcher.rb +0 -17
  232. data/spec/support/unit/shared_examples/set_session_or_flash.rb +0 -360
  233. data/spec/support/unit/validation_matcher_scenario.rb +0 -62
  234. data/spec/unit/shoulda/matchers/action_controller/callback_matcher_spec.rb +0 -82
  235. data/spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb +0 -28
  236. data/spec/unit/shoulda/matchers/action_controller/permit_matcher_spec.rb +0 -592
  237. data/spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb +0 -42
  238. data/spec/unit/shoulda/matchers/action_controller/render_template_matcher_spec.rb +0 -76
  239. data/spec/unit/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb +0 -62
  240. data/spec/unit/shoulda/matchers/action_controller/rescue_from_matcher_spec.rb +0 -90
  241. data/spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb +0 -31
  242. data/spec/unit/shoulda/matchers/action_controller/route_matcher_spec.rb +0 -330
  243. data/spec/unit/shoulda/matchers/action_controller/route_params_spec.rb +0 -30
  244. data/spec/unit/shoulda/matchers/action_controller/set_flash_matcher_spec.rb +0 -67
  245. data/spec/unit/shoulda/matchers/action_controller/set_session_matcher_spec.rb +0 -17
  246. data/spec/unit/shoulda/matchers/action_controller/set_session_or_flash_matcher_spec.rb +0 -562
  247. data/spec/unit/shoulda/matchers/active_model/allow_mass_assignment_of_matcher_spec.rb +0 -115
  248. data/spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb +0 -823
  249. data/spec/unit/shoulda/matchers/active_model/disallow_value_matcher_spec.rb +0 -86
  250. data/spec/unit/shoulda/matchers/active_model/have_secure_password_matcher_spec.rb +0 -20
  251. data/spec/unit/shoulda/matchers/active_model/helpers_spec.rb +0 -162
  252. data/spec/unit/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb +0 -266
  253. data/spec/unit/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb +0 -91
  254. data/spec/unit/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb +0 -149
  255. data/spec/unit/shoulda/matchers/active_model/validate_exclusion_of_matcher_spec.rb +0 -207
  256. data/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb +0 -1015
  257. data/spec/unit/shoulda/matchers/active_model/validate_length_of_matcher_spec.rb +0 -288
  258. data/spec/unit/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb +0 -1837
  259. data/spec/unit/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb +0 -380
  260. data/spec/unit/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb +0 -107
  261. data/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb +0 -1242
  262. data/spec/unit/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb +0 -251
  263. data/spec/unit/shoulda/matchers/active_record/define_enum_for_matcher_spec.rb +0 -168
  264. data/spec/unit/shoulda/matchers/active_record/have_db_column_matcher_spec.rb +0 -111
  265. data/spec/unit/shoulda/matchers/active_record/have_db_index_matcher_spec.rb +0 -85
  266. data/spec/unit/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb +0 -41
  267. data/spec/unit/shoulda/matchers/active_record/serialize_matcher_spec.rb +0 -86
  268. data/spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb +0 -1418
  269. data/spec/unit/shoulda/matchers/doublespeak/double_collection_spec.rb +0 -190
  270. data/spec/unit/shoulda/matchers/doublespeak/double_implementation_registry_spec.rb +0 -21
  271. data/spec/unit/shoulda/matchers/doublespeak/double_spec.rb +0 -271
  272. data/spec/unit/shoulda/matchers/doublespeak/object_double_spec.rb +0 -77
  273. data/spec/unit/shoulda/matchers/doublespeak/proxy_implementation_spec.rb +0 -72
  274. data/spec/unit/shoulda/matchers/doublespeak/stub_implementation_spec.rb +0 -101
  275. data/spec/unit/shoulda/matchers/doublespeak/world_spec.rb +0 -80
  276. data/spec/unit/shoulda/matchers/doublespeak_spec.rb +0 -27
  277. data/spec/unit/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb +0 -43
  278. data/spec/unit/shoulda/matchers/independent/delegate_method_matcher_spec.rb +0 -517
  279. data/spec/unit/shoulda/matchers/routing/route_matcher_spec.rb +0 -242
  280. data/spec/unit/shoulda/matchers/util/word_wrap_spec.rb +0 -252
  281. data/spec/unit_spec_helper.rb +0 -46
  282. data/spec/warnings_spy/filesystem.rb +0 -45
  283. data/spec/warnings_spy/partitioner.rb +0 -36
  284. data/spec/warnings_spy/reader.rb +0 -53
  285. data/spec/warnings_spy/reporter.rb +0 -88
  286. data/spec/warnings_spy.rb +0 -64
  287. data/tasks/documentation.rb +0 -199
  288. data/zeus.json +0 -11
data/NEWS.md DELETED
@@ -1,986 +0,0 @@
1
- # 3.1.0
2
-
3
- ### Bug fixes
4
-
5
- * Update `validate_numericality_of` so that submatchers are applied lazily
6
- instead of immediately. Previously, qualifiers were order-dependent, meaning
7
- that if you used `strict` before you used, say, `odd`, then `strict` wouldn't
8
- actually apply to `odd`. Now the order that you specify qualifiers doesn't
9
- matter.
10
-
11
- * *Source: [6c67a5e]*
12
-
13
- * Fix `allow_value` so that it does not raise an AttributeChangedValueError
14
- (formerly CouldNotSetAttributeError) when used against an attribute that is an
15
- enum in an ActiveRecord model.
16
-
17
- * *Source: [9e8603e]*
18
-
19
- * Add a `ignoring_interference_by_writer` qualifier to all matchers, not just
20
- `allow_value`. *This is enabled by default, which means that you should never
21
- get a CouldNotSetAttributeError again.* (You may get some more information if
22
- a test fails, however.)
23
-
24
- * *Source: [1189934], [5532f43]*
25
- * *Fixes: [#786], [#799], [#801], [#804], [#817], [#841], [#849], [#872],
26
- [#873], and [#874]*
27
-
28
- * Fix `validate_numericality_of` so that it does not blow up when used against
29
- a virtual attribute defined in an ActiveRecord model (that is, an attribute
30
- that is not present in the database but is defined using `attr_accessor`).
31
-
32
- * *Source: [#822]*
33
-
34
- * Update `validate_numericality_of` so that it no longer raises an
35
- IneffectiveTestError if used against a numeric column.
36
-
37
- * *Source: [5ed0362]*
38
- * *Fixes: [#832]*
39
-
40
- [6c67a5e]: https://github.com/thoughtbot/shoulda-matchers/commit/6c67a5eb0df265d3a565aa7d1a7e2b645051eb5a
41
- [9e8603e]: https://github.com/thoughtbot/shoulda-matchers/commit/9e8603eb745bfa2a5aea6dfef85adf680d447151
42
- [1189934]: https://github.com/thoughtbot/shoulda-matchers/commit/118993480604d39c73687d069f7af3726f3e3f3e
43
- [5532f43]: https://github.com/thoughtbot/shoulda-matchers/commit/5532f4359aa332b10de7d46f876eaffd4a95b5b6
44
- [#786]: https://github.com/thoughtbot/shoulda-matchers/issues/786
45
- [#799]: https://github.com/thoughtbot/shoulda-matchers/issues/799
46
- [#801]: https://github.com/thoughtbot/shoulda-matchers/issues/801
47
- [#804]: https://github.com/thoughtbot/shoulda-matchers/issues/804
48
- [#817]: https://github.com/thoughtbot/shoulda-matchers/issues/817
49
- [#841]: https://github.com/thoughtbot/shoulda-matchers/issues/841
50
- [#849]: https://github.com/thoughtbot/shoulda-matchers/issues/849
51
- [#872]: https://github.com/thoughtbot/shoulda-matchers/issues/872
52
- [#873]: https://github.com/thoughtbot/shoulda-matchers/issues/873
53
- [#874]: https://github.com/thoughtbot/shoulda-matchers/issues/874
54
- [#822]: https://github.com/thoughtbot/shoulda-matchers/pull/822
55
- [5ed0362]: https://github.com/thoughtbot/shoulda-matchers/commit/5ed03624197314865ff5463e473e5e84bb91d9ea
56
- [#832]: https://github.com/thoughtbot/shoulda-matchers/issues/832
57
-
58
- ### Features
59
-
60
- * Add a new qualifier, `ignoring_case_sensitivity`, to `validate_uniqueness_of`.
61
- This provides a way to test uniqueness of an attribute whose case is
62
- normalized, either in a custom writer method for that attribute, or in a
63
- custom `before_validation` callback.
64
-
65
- * *Source: [#840]*
66
- * *Fixes: [#836]*
67
-
68
- [#840]: https://github.com/thoughtbot/shoulda-matchers/pull/840
69
- [#836]: https://github.com/thoughtbot/shoulda-matchers/issues/836
70
-
71
- ### Improvements
72
-
73
- * Improve failure messages and descriptions of all matchers across the board so
74
- that it is easier to understand what the matcher was doing when it failed.
75
- (You'll see a huge difference in the output of the numericality and uniqueness
76
- matchers in particular.)
77
-
78
- * Matchers now raise an error if any attributes that the matcher is attempting
79
- to set do not exist on the model.
80
-
81
- * *Source: [2962112]*
82
-
83
- * Update `validate_numericality_of` so that it doesn't always run all of the
84
- submatchers, but stops on the first one that fails. Since failure messages
85
- now contain information as to what value the matcher set on the attribute when
86
- it failed, this change guarantees that the correct value will be shown.
87
-
88
- * *Source: [8e24a6e]*
89
-
90
- * Continue to detect if attributes change incoming values, but now instead of
91
- immediately seeing a CouldNotSetAttributeError, you will only be informed
92
- about it if the test you've written fails.
93
-
94
- * *Source: [1189934]*
95
-
96
- * Add an additional check to `define_enum_for` to ensure that the column that
97
- underlies the enum attribute you're testing is an integer column.
98
-
99
- * *Source: [68dd70a]*
100
-
101
- * Add a test for `validate_numericality_of` so that it officially supports money
102
- columns.
103
-
104
- * *Source: [a559713]*
105
- * *Refs: [#841]*
106
-
107
- [2962112]: https://github.com/thoughtbot/shoulda-matchers/commit/296211211497e624dde87adae68b385ad4cdae3a
108
- [8e24a6e]: https://github.com/thoughtbot/shoulda-matchers/commit/8e24a6e9b2b147f2c51fb03aa02543f213acab34
109
- [68dd70a]: https://github.com/thoughtbot/shoulda-matchers/commit/68dd70a23d8997a490683adcd2108a4a5cadf8ba
110
- [a559713]: https://github.com/thoughtbot/shoulda-matchers/commit/a559713f96303414551c0bc1767fb11eb19bcc5d
111
-
112
- # 3.0.1
113
-
114
- ### Bug fixes
115
-
116
- * Fix `validate_inclusion_of` + `in_array` when used against a date or datetime
117
- column/attribute so that it does not raise a CouldNotSetAttributeError.
118
- ([#783], [8fa97b4])
119
-
120
- * Fix `validate_numericality_of` when used against a numeric column so that it
121
- no longer raises a CouldNotSetAttributeError if the matcher has been qualified
122
- in any way (`only_integer`, `greater_than`, `odd`, etc.). ([#784], [#812])
123
-
124
- ### Improvements
125
-
126
- * `validate_uniqueness_of` now raises a NonCaseSwappableValueError if the value
127
- the matcher is using to test uniqueness cannot be case-swapped -- in other
128
- words, if it doesn't contain any alpha characters. When this is the case, the
129
- matcher cannot work effectively. ([#789], [ada9bd3])
130
-
131
- [#783]: https://github.com/thoughtbot/shoulda-matchers/pull/783
132
- [8fa97b4]: https://github.com/thoughtbot/shoulda-matchers/commit/8fa97b4ff33b57ce16dfb96be1ec892502f2aa9e
133
- [#784]: https://github.com/thoughtbot/shoulda-matchers/pull/784
134
- [#789]: https://github.com/thoughtbot/shoulda-matchers/pull/789
135
- [ada9bd3]: https://github.com/thoughtbot/shoulda-matchers/commit/ada9bd3a1b9f2bb9fa74d0dfe1f8f7080314298c
136
- [#812]: https://github.com/thoughtbot/shoulda-matchers/pull/812
137
-
138
- # 3.0.0
139
-
140
- ### Backward-incompatible changes
141
-
142
- * We've dropped support for Rails 3.x, Ruby 1.9.2, and Ruby 1.9.3, and RSpec 2.
143
- All of these have been end-of-lifed. ([a4045a1], [b7fe87a], [32c0e62])
144
-
145
- * The gem no longer detects the test framework you're using or mixes itself into
146
- that framework automatically. [History][no-auto-integration-1] has
147
- [shown][no-auto-integration-2] that performing any kind of detection is prone
148
- to bugs and more complicated than it should be.
149
-
150
- Here are the updated instructions:
151
-
152
- * You no longer need to say `require: false` in your Gemfile; you can
153
- include the gem as normal.
154
- * You'll need to add the following somewhere in your `rails_helper` (for
155
- RSpec) or `test_helper` (for Minitest / Test::Unit):
156
-
157
- ``` ruby
158
- Shoulda::Matchers.configure do |config|
159
- config.integrate do |with|
160
- # Choose a test framework:
161
- with.test_framework :rspec
162
- with.test_framework :minitest
163
- with.test_framework :minitest_4
164
- with.test_framework :test_unit
165
-
166
- # Choose one or more libraries:
167
- with.library :active_record
168
- with.library :active_model
169
- with.library :action_controller
170
- # Or, choose the following (which implies all of the above):
171
- with.library :rails
172
- end
173
- end
174
- ```
175
-
176
- ([1900071])
177
-
178
- * Previously, under RSpec, all of the matchers were mixed into all of the
179
- example groups. This created a problem because some gems, such as
180
- [active_model_serializers-matchers], provide matchers that share the same
181
- name as some of our own matchers. Now, matchers are only mixed into whichever
182
- example group they belong to:
183
-
184
- * ActiveModel and ActiveRecord matchers are available only in model example
185
- groups.
186
- * ActionController matchers are available only in controller example groups.
187
- * The `route` matcher is available only in routing example groups.
188
-
189
- ([af98a23], [8cf449b])
190
-
191
- * There are two changes to `allow_value`:
192
-
193
- * The negative form of `allow_value` has been changed so that instead of
194
- asserting that any of the given values is an invalid value (allowing good
195
- values to pass through), assert that *all* values are invalid values
196
- (allowing good values not to pass through). This means that this test which
197
- formerly passed will now fail:
198
-
199
- ``` ruby
200
- expect(record).not_to allow_value('good value', *bad_values)
201
- ```
202
-
203
- ([19ce8a6])
204
-
205
- * `allow_value` now raises a CouldNotSetAttributeError if in setting the
206
- attribute, the value of the attribute from reading the attribute back is
207
- different from the one used to set it.
208
-
209
- This would happen if the writer method for that attribute has custom logic
210
- to ignore certain incoming values or change them in any way. Here are three
211
- examples we've seen:
212
-
213
- * You're attempting to assert that an attribute should not allow nil, yet
214
- the attribute's writer method contains a conditional to do nothing if
215
- the attribute is set to nil:
216
-
217
- ``` ruby
218
- class Foo
219
- include ActiveModel::Model
220
-
221
- attr_reader :bar
222
-
223
- def bar=(value)
224
- return if value.nil?
225
- @bar = value
226
- end
227
- end
228
-
229
- describe Foo do
230
- it do
231
- foo = Foo.new
232
- foo.bar = "baz"
233
- # This will raise a CouldNotSetAttributeError since `foo.bar` is now "123"
234
- expect(foo).not_to allow_value(nil).for(:bar)
235
- end
236
- end
237
- ```
238
-
239
- * You're attempting to assert that an numeric attribute should not allow a
240
- string that contains non-numeric characters, yet the writer method for
241
- that attribute strips out non-numeric characters:
242
-
243
- ``` ruby
244
- class Foo
245
- include ActiveModel::Model
246
-
247
- attr_reader :bar
248
-
249
- def bar=(value)
250
- @bar = value.gsub(/\D+/, '')
251
- end
252
- end
253
-
254
- describe Foo do
255
- it do
256
- foo = Foo.new
257
- # This will raise a CouldNotSetAttributeError since `foo.bar` is now "123"
258
- expect(foo).not_to allow_value("abc123").for(:bar)
259
- end
260
- end
261
- ```
262
-
263
- * You're passing a value to `allow_value` that the model typecasts into
264
- another value:
265
-
266
- ``` ruby
267
- describe Foo do
268
- # Assume that `attr` is a string
269
- # This will raise a CouldNotSetAttributeError since `attr` typecasts `[]` to `"[]"`
270
- it { should_not allow_value([]).for(:attr) }
271
- end
272
- ```
273
-
274
- With all of these failing examples, why are we making this change? We want
275
- to guard you (as the developer) from writing a test that you think acts one
276
- way but actually acts a different way, as this could lead to a confusing
277
- false positive or negative.
278
-
279
- If you understand the problem and wish to override this behavior so that
280
- you do not get a CouldNotSetAttributeError, you can add the
281
- `ignoring_interference_by_writer` qualifier like so. Note that this will not
282
- always cause the test to pass.
283
-
284
- ``` ruby
285
- it { should_not allow_value([]).for(:attr).ignoring_interference_by_writer }
286
- ```
287
-
288
- ([9d9dc4e])
289
-
290
- * `validate_uniqueness_of` is now properly case-sensitive by default, to match
291
- the default behavior of the validation itself. This is a backward-incompatible
292
- change because this test which incorrectly passed before will now fail:
293
-
294
- ``` ruby
295
- class Product < ActiveRecord::Base
296
- validates_uniqueness_of :name, case_sensitive: false
297
- end
298
-
299
- describe Product do
300
- it { is_expected.to validate_uniqueness_of(:name) }
301
- end
302
- ```
303
-
304
- ([57a1922])
305
-
306
- * `ensure_inclusion_of`, `ensure_exclusion_of`, and `ensure_length_of` have been
307
- removed in favor of their `validate_*` counterparts. ([55c8d09])
308
-
309
- * `set_the_flash` and `set_session` have been changed to more closely align with
310
- each other:
311
- * `set_the_flash` has been removed in favor of `set_flash`. ([801f2c7])
312
- * `set_session('foo')` is no longer valid syntax, please use
313
- `set_session['foo']` instead. ([535fe05])
314
- * `set_session['key'].to(nil)` will no longer pass when the key in question
315
- has not been set yet. ([535fe05])
316
-
317
- * Change `set_flash` so that `set_flash[:foo].now` is no longer valid syntax.
318
- You'll want to use `set_flash.now[:foo]` instead. This was changed in order to
319
- more closely align with how `flash.now` works when used in a controller.
320
- ([#755], [#752])
321
-
322
- * Change behavior of `validate_uniqueness_of` when the matcher is not
323
- qualified with any scopes, but your validation is. Previously the following
324
- test would pass when it now fails:
325
-
326
- ``` ruby
327
- class Post < ActiveRecord::Base
328
- validate :slug, uniqueness: { scope: :user_id }
329
- end
330
-
331
- describe Post do
332
- it { should validate_uniqueness_of(:slug) }
333
- end
334
- ```
335
-
336
- ([6ac7b81])
337
-
338
- [active_model_serializers-matchers]: https://github.com/adambarber/active_model_serializers-matchers
339
- [no-auto-integration-1]: https://github.com/freerange/mocha/commit/049080c673ee3f76e76adc1e1a6122c7869f1648
340
- [no-auto-integration-2]: https://github.com/rr/rr/issues/29
341
- [1900071]: https://github.com/thoughtbot/shoulda-matchers/commit/190007155e0676aae84d08d8ed8eed3beebc3a06
342
- [b7fe87a]: https://github.com/thoughtbot/shoulda-matchers/commit/b7fe87ae915f6b1f99d64e847fea536ad0f78024
343
- [a4045a1]: https://github.com/thoughtbot/shoulda-matchers/commit/a4045a1f9bc454e618a7c55960942eb030f02fdd
344
- [57a1922]: https://github.com/thoughtbot/shoulda-matchers/commit/57a19228b6a85f12ba7a79a26dae5869c1499c6d
345
- [19ce8a6]: https://github.com/thoughtbot/shoulda-matchers/commit/19c38a642a2ae1316ef12540a0185cd026901e74
346
- [eaaa2d8]: https://github.com/thoughtbot/shoulda-matchers/commit/eaaa2d83e5cd31a3ca0a1aaa65441ea1a4fffa49
347
- [55c8d09]: https://github.com/thoughtbot/shoulda-matchers/commit/55c8d09bf2af886540924efa83c3b518d926a770
348
- [801f2c7]: https://github.com/thoughtbot/shoulda-matchers/commit/801f2c7c1eab3b2053244485c9800f850959cfef
349
- [535fe05]: https://github.com/thoughtbot/shoulda-matchers/commit/535fe05be8686fdafd8b22f2ed5c4192bd565d50
350
- [6ac7b81]: https://github.com/thoughtbot/shoulda-matchers/commit/6ac7b8158cfba3b518eb3da3c24345e4473b416f
351
- [#755]: https://github.com/thoughtbot/shoulda-matchers/pull/755
352
- [#752]: https://github.com/thoughtbot/shoulda-matchers/pull/752
353
- [9d9dc4e]: https://github.com/thoughtbot/shoulda-matchers/commit/9d9dc4e6b9cf2c19df66a1b4ba432ad8d3e5dded
354
- [32c0e62]: https://github.com/thoughtbot/shoulda-matchers/commit/32c0e62596b87e37a301f87bbe21cfcc77750552
355
- [af98a23]: https://github.com/thoughtbot/shoulda-matchers/commit/af98a23091551fb40aded5a8d4f9e5be926f53a9
356
- [8cf449b]: https://github.com/thoughtbot/shoulda-matchers/commit/8cf449b4ca37d0d7446d2cabbfa5a1582358256d
357
-
358
- ### Bug fixes
359
-
360
- * So far the tests for the gem have been running against only SQLite. Now they
361
- run against PostgreSQL, too. As a result we were able to fix some
362
- Postgres-related bugs, specifically around `validate_uniqueness_of`:
363
-
364
- * When scoped to a UUID column that ends in an "f", the matcher is able to
365
- generate a proper "next" value without erroring. ([#402], [#587], [#662])
366
-
367
- * Support scopes that are PostgreSQL array columns. Please note that this is
368
- only supported for Rails 4.2 and greater, as versions before this cannot
369
- handle array columns correctly, particularly in conjunction with the
370
- uniqueness validator. ([#554])
371
-
372
- * Fix so that when scoped to a text column and the scope is set to nil before
373
- running it through the matcher, the matcher does not fail. ([#521], [#607])
374
-
375
- * Fix `define_enum_for` so that it actually tests that the attribute is present
376
- in the list of defined enums, as you could fool it by merely defining a class
377
- method that was the pluralized version of the attribute name. In the same
378
- vein, passing a pluralized version of the attribute name to `define_enum_for`
379
- would erroneously pass, and now it fails. ([#641])
380
-
381
- * Fix `permit` so that it does not break the functionality of
382
- ActionController::Parameters#require. ([#648], [#675])
383
-
384
- * Fix `validate_uniqueness_of` + `scoped_to` so that it does not raise an error
385
- if a record exists where the scoped attribute is nil. ([#677])
386
-
387
- * Fix `route` matcher so if your route includes a default `format`, you can
388
- specify this as a symbol or string. ([#693])
389
-
390
- * Fix `validate_uniqueness_of` so that it allows you to test against scoped
391
- attributes that are boolean columns. ([#457], [#694])
392
-
393
- * Fix failure message for `validate_numericality_of` as it sometimes didn't
394
- provide the reason for failure. ([#699])
395
-
396
- * Fix `shoulda/matchers/independent` so that it can be required
397
- independently, without having to require all of the gem. ([#746], [e0a0200])
398
-
399
- ### Features
400
-
401
- * Add `on` qualifier to `permit`. This allows you to make an assertion that
402
- a restriction was placed on a slice of the `params` hash and not the entire
403
- `params` hash. Although we don't require you to use this qualifier, we do
404
- recommend it, as it's a more precise check. ([#675])
405
-
406
- * Add `strict` qualifier to `validate_numericality_of`. ([#620])
407
-
408
- * Add `on` qualifier to `validate_numericality_of`. ([9748869]; h/t [#356],
409
- [#358])
410
-
411
- * Add `join_table` qualifier to `have_and_belong_to_many`. ([#556])
412
-
413
- * `allow_values` is now an alias for `allow_value`. This makes more sense when
414
- checking against multiple values:
415
-
416
- ``` ruby
417
- it { should allow_values('this', 'and', 'that') }
418
- ```
419
-
420
- ([#692])
421
-
422
- [9748869]: https://github.com/thoughtbot/shoulda-matchers/commit/97488690910520ed8e1f2e164b1982eff5ef1f19
423
- [#402]: https://github.com/thoughtbot/shoulda-matchers/pull/402
424
- [#587]: https://github.com/thoughtbot/shoulda-matchers/pull/587
425
- [#662]: https://github.com/thoughtbot/shoulda-matchers/pull/662
426
- [#554]: https://github.com/thoughtbot/shoulda-matchers/pull/554
427
- [#641]: https://github.com/thoughtbot/shoulda-matchers/pull/641
428
- [#521]: https://github.com/thoughtbot/shoulda-matchers/pull/521
429
- [#607]: https://github.com/thoughtbot/shoulda-matchers/pull/607
430
- [#648]: https://github.com/thoughtbot/shoulda-matchers/pull/648
431
- [#675]: https://github.com/thoughtbot/shoulda-matchers/pull/675
432
- [#677]: https://github.com/thoughtbot/shoulda-matchers/pull/677
433
- [#620]: https://github.com/thoughtbot/shoulda-matchers/pull/620
434
- [#693]: https://github.com/thoughtbot/shoulda-matchers/pull/693
435
- [#356]: https://github.com/thoughtbot/shoulda-matchers/pull/356
436
- [#358]: https://github.com/thoughtbot/shoulda-matchers/pull/358
437
- [#556]: https://github.com/thoughtbot/shoulda-matchers/pull/556
438
- [#457]: https://github.com/thoughtbot/shoulda-matchers/pull/457
439
- [#694]: https://github.com/thoughtbot/shoulda-matchers/pull/694
440
- [#692]: https://github.com/thoughtbot/shoulda-matchers/pull/692
441
- [#699]: https://github.com/thoughtbot/shoulda-matchers/pull/699
442
- [#746]: https://github.com/thoughtbot/shoulda-matchers/pull/746
443
- [e0a0200]: https://github.com/thoughtbot/shoulda-matchers/commit/e0a0200fe47157c161fb206043540804bdad664e
444
-
445
- # 2.8.0
446
-
447
- ### Deprecations
448
-
449
- * `ensure_length_of` has been renamed to `validate_length_of`.
450
- `ensure_length_of` is deprecated and will be removed in 3.0.0.
451
-
452
- * `set_the_flash` has been renamed to `set_flash`. `set_the_flash` is
453
- deprecated and will be removed in 3.0.0.
454
-
455
- * `set_session(:foo)` is deprecated in favor of `set_session[:foo]`.
456
- `set_session(:foo)` will be invalid syntax in 3.0.0.
457
-
458
- * Using `should set_session[:key].to(nil)` to assert that that a value has not
459
- been set is deprecated. Please use `should_not set_session[:key]` instead.
460
- In 3.0.0, `should set_session[:key].to(nil)` will only pass if the value is
461
- truly nil.
462
-
463
- ### Bug fixes
464
-
465
- * Fix `delegate_method` so that it works again with shoulda-context. ([#591])
466
-
467
- * Fix `validate_uniqueness_of` when used with `scoped_to` so that when one of
468
- the scope attributes is a polymorphic `*_type` attribute and the model has
469
- another validation on the same attribute, the matcher does not fail with an
470
- error. ([#592])
471
-
472
- * Fix `has_many` used with `through` so that when the association does not
473
- exist, and the matcher fails, it does not raise an error when producing the
474
- failure message. ([#588])
475
-
476
- * Fix `have_and_belong_to_many` used with `join_table` so that it does not fail
477
- when `foreign_key` and/or `association_foreign_key` was specified on the
478
- association as a symbol instead of a string. ([#584])
479
-
480
- * Fix `allow_value` when an i18n translation key is passed to `with_message` and
481
- the `:against` option is used to specify an alternate attribute. A bug here
482
- also happened to affect `validate_confirmation_of` when an i18n translation
483
- key is passed to `with_message`. ([#593])
484
-
485
- * Fix `class_name` qualifier for association matchers so that if the model being
486
- referenced is namespaced, the matcher will correctly resolve the class before
487
- checking it against the association's `class_name`. ([#537])
488
-
489
- * Fix `validate_inclusion_of` used with `with_message` so that it fails if given
490
- a message that does not match the message on the validation. ([#598])
491
-
492
- * Fix `route` matcher so that when controller and action are specified in hash
493
- notation (e.g. `posts#show`), route parameters such as `id` do not need to be
494
- specified as a string but may be specified as a number as well. ([#602])
495
-
496
- ### Features
497
-
498
- * Add ability to test `:primary_key` option on associations. ([#597])
499
-
500
- * Add `allow_blank` qualifier to `validate_uniqueness_of` to complement
501
- the `allow_blank` option. ([#543])
502
-
503
- * Change `set_session` so that #[] and #to qualifiers are optional, similar to
504
- `set_flash`. That is, you can now say `should set_session` to assert that any
505
- flash value has been set, or `should set_session.to('value')` to assert that
506
- any value in the session is 'value'.
507
-
508
- * Change `set_session` so that its #to qualifier supports regexps, similar to
509
- `set_flash`.
510
-
511
- * Add `with_prefix` qualifier to `delegate_method` to correspond to the `prefix`
512
- option for Rails's `delegate` macro. ([#622])
513
-
514
- * Add support for Rails 4.2, especially fixing `serialize` matcher to remove
515
- warning about `serialized_attributes` being deprecated. ([#627])
516
-
517
- * Update `dependent` qualifier on association matchers to support `:destroy`,
518
- `:delete`, `:nullify`, `:restrict`, `:restrict_with_exception`, and
519
- `:restrict_with_error`. You can also pass `true` or `false` to assert that
520
- the association has (or has not) been declared with *any* dependent option.
521
- ([#631])
522
-
523
- ### Improvements
524
-
525
- * Tweak `allow_value` failure message so that it reads a bit nicer when listing
526
- existing errors.
527
-
528
- [#591]: https://github.com/thoughtbot/shoulda-matchers/pull/591
529
- [#592]: https://github.com/thoughtbot/shoulda-matchers/pull/592
530
- [#588]: https://github.com/thoughtbot/shoulda-matchers/pull/588
531
- [#584]: https://github.com/thoughtbot/shoulda-matchers/pull/584
532
- [#593]: https://github.com/thoughtbot/shoulda-matchers/pull/593
533
- [#597]: https://github.com/thoughtbot/shoulda-matchers/pull/597
534
- [#537]: https://github.com/thoughtbot/shoulda-matchers/pull/537
535
- [#598]: https://github.com/thoughtbot/shoulda-matchers/pull/598
536
- [#602]: https://github.com/thoughtbot/shoulda-matchers/pull/602
537
- [#543]: https://github.com/thoughtbot/shoulda-matchers/pull/543
538
- [#622]: https://github.com/thoughtbot/shoulda-matchers/pull/622
539
- [#627]: https://github.com/thoughtbot/shoulda-matchers/pull/627
540
- [#631]: https://github.com/thoughtbot/shoulda-matchers/pull/631
541
-
542
- # 2.7.0
543
-
544
- ### Deprecations
545
-
546
- * `ensure_inclusion_of` has been renamed to `validate_inclusion_of`.
547
- `ensure_inclusion_of` is deprecated and will be removed in 3.0.0.
548
-
549
- * `ensure_exclusion_of` has been renamed to `validate_exclusion_of`.
550
- `ensure_exclusion_of` is deprecated and will be removed in 3.0.0.
551
-
552
- ### Bug fixes
553
-
554
- * Fix `delegate_method` so that it does not raise an error if the method that
555
- returns the delegate object is private.
556
-
557
- * Warn when `ensure_inclusion_of` is chained with `.in_array([false, true])`
558
- as well as with `.in_array([true, false])`.
559
-
560
- * Fix `set_session` so that the `to` qualifier if given nil checks that the
561
- session variable in question was set to nil (previously this actually did
562
- nothing).
563
-
564
- * Fix `filter_param` so that it works when `config.filter_parameters` contains
565
- regexes.
566
-
567
- * Fix `delegate_method` so that it can be required independent of Active
568
- Support.
569
-
570
- * Fix `validate_uniqueness_of`. When used against an unpersisted record whose
571
- model contained a non-nullable column other than the one being validated, the
572
- matcher would break. Even if the test set that column to a value beforehand,
573
- the record had to be persisted in order for the matcher to work. Now this is
574
- no longer the case and the record can remain unpersisted.
575
-
576
- * Fix `validate_absence_of`: it required that a string be passed as the
577
- attribute name rather than a symbol (which is the usual and documented usage).
578
-
579
- ### Features
580
-
581
- * Add new matcher `define_enum_for` to test usage of the `enum` macro introduced
582
- in Rails 4.1.
583
-
584
- ### Improvements
585
-
586
- * `have_and_belongs_to_many` now checks to make sure that the join table
587
- contains the correct columns for the left- and right-hand side of the
588
- association.
589
-
590
- * Reword failure message for `delegate_method` so that it's a little more
591
- helpful.
592
-
593
- # 2.6.2
594
-
595
- ### Bug fixes
596
-
597
- * If you have a Rails >= 4.1 project and you are running tests using Spring,
598
- matchers that depend on assertions within Rails' testing layer (e.g.
599
- `render_template` and `route`) will no longer fail.
600
-
601
- * Fix `permit` so that it can be used more than once in the same test.
602
-
603
- * Revert change to `validate_uniqueness_of` made in 2.6.0 so that it no longer
604
- provides default values for non-primary, non-nullable columns. This approach
605
- was causing test failures because it makes the assumption that none of these
606
- columns allow only specific values, which is not true. If you get an error
607
- from `validate_uniqueness_of`, your best bet continues to be creating a record
608
- manually and calling `validate_uniqueness_of` on that instead.
609
-
610
- * The majority of warnings that the gem produced have been removed. The gem
611
- still produces warnings under Ruby 1.9.3; we will address this in a future
612
- release.
613
-
614
- # 2.6.1
615
-
616
- ### Bug fixes
617
-
618
- * Revert changes to `validate_numericality_of` made in the last release, which
619
- made it so that comparison qualifiers specified on the validation are tested
620
- using a very small decimal number offset rather than a whole number by
621
- default, except if the matcher was qualified with `only_integer`. This means
622
- that prior to 2.6.0, if your validation specified `only_integer` and you did
623
- not, then after 2.6.0 that test would fail. This is now fixed.
624
-
625
- * Fix regression in previous release where ActiveRecord matchers would not be
626
- included when ActiveRecord wasn't defined (i.e. if you were using ActiveModel
627
- only).
628
-
629
- * Revert the behavior of `allow_value` changed in 2.6.0 (it will no longer raise
630
- CouldNotClearAttribute). This was originally done as a part of a fix for
631
- `validate_presence_of` when used in conjunction with `has_secure_password`.
632
- That fix has been updated so that it does not affect `allow_value`.
633
-
634
- * Fix callback matchers and correct test coverage.
635
-
636
- * Fix `permit` so that it does not interfere with different usages of `params`
637
- in your controller action. Specifically, this will not raise an error:
638
- `params.fetch(:foo, {}).permit(:bar, :baz)` (the `permit` will have no
639
- problems recognizing that :bar and :baz are permitted params).
640
-
641
- * Fix `permit` on Rails 4.1 to use PATCH by default for #update instead of PUT.
642
- Previously you had to specify this manually.
643
-
644
- * Fix `permit` so that it track multiple calls to #permit in your controller
645
- action. Previously only the last usage of #permit would be considered in
646
- determining whether the matcher matched.
647
-
648
- * Fix `permit` so that if the route for your action requires params (such as id)
649
- then you can now specify those params:
650
- `permit(:first_name, :last_name).for(:update, params: { id: 42 })`.
651
-
652
- * Fix `delegate_method` so that it does not stub the target method forever,
653
- returning it to its original implementation after the match ends.
654
-
655
- * Fix `validate_uniqueness_of` to work with Rails 4.1 enum columns.
656
-
657
- ### Features
658
-
659
- * Teach `with_message` qualifier on `allow_value` to accept a hash of i18n
660
- interpolation values:
661
- `allow_value('foo').for(:attr).with_message(:greater_than, values: { count: 20 })`.
662
-
663
- # 2.6.0
664
-
665
- * The boolean argument to `have_db_index`'s `unique` option is now optional, for
666
- consistency with other matchers.
667
-
668
- * Association matchers now test that the model being referred to (either
669
- implicitly or explicitly, using `:class_name`) actually exists.
670
-
671
- * Add ability to test `:autosave` option on associations.
672
-
673
- * Fix `validate_uniqueness_of(...).allow_nil` so that it can be used against an
674
- non-password attribute which is in a model that `has_secure_password`. Doing
675
- so previously would result in a "Password digest missing on new record" error.
676
-
677
- * Fix description for `validate_numericality_of` so that if the matcher fails,
678
- the error message reported does not say the matcher accepts integer values if
679
- you didn't specify that.
680
-
681
- * Fix `ensure_inclusion_of` so that you can use it against a boolean column
682
- (and pass boolean values to `in_array`). There are two caveats:
683
-
684
- * You should not test that your attribute allows both true and false
685
- (`.in_array([true, false]`); there's no way to test that it doesn't accept
686
- anything other than that.
687
- * You cannot test that your attribute allows nil (`.in_array([nil])`) if
688
- the column does not allow null values.
689
-
690
- * Change `validate_uniqueness_of(...)` so that it provides default values for
691
- non-nullable attributes.
692
-
693
- * Running `rake` now installs Appraisals before running the test suite.
694
- (Additionally, we now manage Appraisals using the `appraisal` executable in
695
- Appraisal 1.0.0.)
696
-
697
- * Add `allow_nil` option to `validate_numericality_of` so that you can validate
698
- that numeric values are validated only if a value is supplied.
699
-
700
- * Fix `validate_numericality_of` so that test fails when the value with
701
- `greater_than`, `greater_than_or_equal_to`, `less_than`, `less_than_or_equal_
702
- to` or `equal_to` is not appropriate.
703
-
704
- * Change `validate_presence_of` under Rails 4 so that if you are using it with a
705
- user whose model `has_secure_password` and whose password is set to a value,
706
- you will be instructed to use a user whose password is blank instead. The
707
- reason for this change is due to the fact that Rails 4's version of
708
- `has_secure_password` defines #password= such that `nil` will be ignored,
709
- which interferes with how `validate_presence_of` works.
710
-
711
- * Add ability to test `belongs_to` associations defined with `:inverse_of`.
712
-
713
- * Add back matchers that were removed in 2.0.0: `permit`, for testing strong
714
- parameters, and `delegate_method`, for testing delegation.
715
-
716
- * Add new matchers for testing controller filters: `before_filter`,
717
- `after_filter`, and `around_filter` (aliased to `before_action`,
718
- `after_action` and `around_action` for Rails 4).
719
-
720
- * Fix `rescue_from` matcher so that it does not raise an error when testing
721
- a method handler which has been marked as protected or private.
722
-
723
- * Fix compatibility issues with Rails 4.1:
724
- * `set_the_flash` and `have_and_belongs_to_many` no longer raise errors
725
- * Minitest no longer prints warnings whenever shoulda-matchers is required
726
-
727
- # v 2.5.0
728
-
729
- * Fix Rails/Test::Unit integration to ensure that the test case classes we are
730
- re-opening actually exist.
731
-
732
- * Fix `ensure_length_of` so that it uses the right message to validate when
733
- `is_equal_to` is specified in conjunction with a custom message.
734
-
735
- * The `route` matcher now accepts specifying a controller/action pair as a
736
- string instead of only a hash (e.g. `route(...).to('posts#index')` instead of
737
- `route(...).to(controller: 'posts', action: 'index')`).
738
-
739
- * The `ensure_inclusion_of` matcher now works with a decimal column.
740
-
741
- * Under Rails 3, if you had an association matcher chained with the
742
- the `order` submatcher -- e.g. `should have_many(:foos).order(:bar)` -- and
743
- your association had an `:include` on it, using the matcher would raise an
744
- error. This has been fixed.
745
-
746
- * Fix `validate_uniqueness_of` so it doesn't fail if the attribute under
747
- test has a limit of fewer than 16 characters.
748
-
749
- * You can now test that your `has_many :through` or `has_one :through`
750
- associations are defined with a `:source` option.
751
-
752
- * Add new matcher `validates_absence_of`.
753
-
754
- * Update matchers so that they use `failure_message` and
755
- `failure_message_when_negated` to define error messages. These are new methods
756
- in the upcoming RSpec 3 release which replace `failure_message_for_should` and
757
- `failure_message_for_should_not`. We've kept backward compatibility so all of
758
- your existing tests should still work -- this is just to make sure when RSpec
759
- 3 is released you don't get a bunch of warnings.
760
-
761
- # v 2.4.0
762
-
763
- * Fix a bug with the `validate_numericality_of` matcher that would not allow the
764
- `with_message` option on certain submatchers.
765
-
766
- * Fix a regression with context-dependent validations in ActiveResource
767
-
768
- * shoulda-matchers is now fully compatible with Rails 4.
769
-
770
- * When not using RSpec, shoulda-matchers is now auto-included into
771
- ActiveSupport::TestCase instead of Test::Unit::TestCase (in Rails 4
772
- the former no longer inherits from the latter).
773
-
774
- # v 2.3.0
775
-
776
- * Fix a bug in `ensure_inclusion_of` that would cause issues with using
777
- `in_array` with an integer value.
778
-
779
- * Add support for PostgreSQL UUID columns to `validates_uniqueness_of` (#334).
780
-
781
- * Fix `validates_numericality_of` so that `is_equal_to` submatcher works
782
- correctly (#326).
783
-
784
- * Fix context support for validation matchers and disallowed values (#313).
785
-
786
- * Add a `counter_cache` submatcher for `belongs_to` associations (#311).
787
-
788
- * Add a `rescue_from` matcher for Rails controllers which checks that the
789
- correct ActiveSupport call has been made and that the handlers exist without
790
- actually throwing an exception (#287).
791
-
792
- * Changed the scope of AssociationMatcher methods from protected to private.
793
-
794
- * Extracted `#order`, `#through`, and `#dependent` from AssociationMatcher as
795
- their own submatchers.
796
-
797
- # v 2.2.0
798
-
799
- * Fix `have_and_belong_to_many` matcher issue for Rails 4.
800
-
801
- * Fix `validate_uniqueness_of.scoped_to` issue when the scoped field is already
802
- taken (#207).
803
-
804
- * Add comparison submatchers to `validate_numericality_of` to correspond to the
805
- comparison options you can give to `validates_numericality_of` (#244).
806
-
807
- # v 2.1.0
808
-
809
- * Add missing `failure_message_for_should_not` implementations to
810
- `validate_numericality_of` and its submatchers
811
-
812
- * Support validation contexts for testing validations `on: :create` and when
813
- using custom contexts like `model.valid?(:my_context)`.
814
-
815
- * Fix a bug in validations with autosaved models.
816
-
817
- * Fix maximum value detection for the `ensure_inclusion_of` and
818
- `ensure_exclusion_of` matchers.
819
-
820
- * Add `:odd` and `:even` options to the `validate_numericality_of` matcher.
821
-
822
- * Add `:touch` option to AssociationMatcher.
823
-
824
- * Ruby 2.0.0 is now officially supported.
825
-
826
- * Fix the issue where using `%{attribute}` or `%{model}` in I18n translations
827
- raised exceptions.
828
-
829
- * Support datetime columns in `validate_uniqueness_of.scoped_to`.
830
-
831
- * Add `allow_nil` option to the `validate_uniqueness_of` matcher.
832
-
833
- # v 2.0.0
834
- * Remove the following matchers:
835
- * `assign_to`
836
- * `respond_with_content_type`
837
- * `query_the_database`
838
- * `validate_format_of`
839
- * `have_sent_email`
840
- * `permit` (strong parameters matcher)
841
- * `delegate_method`
842
-
843
- * For more information about 2.0 changes, see:
844
- http://robots.thoughtbot.com/post/47031676783/shoulda-matchers-2-0.
845
-
846
- # v 1.5.6
847
- * Revert previous change in AllowValueMatcher that added a check for a
848
- properly-set attribute.
849
-
850
- # v 1.5.5
851
- * AllowValueMatcher checks that the right value is used for attempts at
852
- setting the attribute with it.
853
- * Please note that previously-passing tests might now fail. It is likely that
854
- it's not a bug, but please make sure that the code you're testing is written
855
- properly before submitting an issue.
856
-
857
- * Use DisallowValueMatcher for `disallows_value_of` method.
858
-
859
- * Assert `class_name` value on real class name for AssociationMatcher.
860
-
861
- * Correct the variable used for `validate_confirmation_of` matcher description.
862
-
863
- # v 1.5.4
864
- * Properly-released version of 1.5.3.
865
-
866
- # v 1.5.3 - yanked due to mis-release
867
- * Alleviate the need to add `rspec` gem to your app.
868
-
869
- # v 1.5.1
870
- * Bump version dependency of Bourne to allow for Mocha upgrade.
871
-
872
- * Should fix incompatibility with MiniTest.
873
-
874
- # v 1.5.0
875
- * Deprecate the following matchers:
876
- * `assign_to`
877
- * `respond_with_content_type`
878
- * `query_the_database`
879
- * `validate_format_of`
880
- * `have_sent_email`
881
- * `permit` (strong parameters matcher)
882
- * `delegate_method`
883
-
884
- * Use RSpec's native `configure.include` syntax for including matchers into
885
- RSpec (#204).
886
-
887
- * Do not force MiniTest loading when test-unit is available (this was fixed
888
- before 1.3.0 then reverted in 1.3.0).
889
-
890
- # v1.4.2
891
- * Add a new `delegate_method` matcher.
892
-
893
- # v1.4.1
894
- * Fix an issue when used with Test::Unit on the allow value matcher.
895
-
896
- * Fix an issue with using `ensure_inclusion_of(:attr)` given an array of true or false values.
897
-
898
- # v1.4.0
899
-
900
- * Add `strict` option to validation matchers.
901
-
902
- * Verify that arguments to `set_the_flash` matcher are valid.
903
-
904
- * Fix issue in ValidateUniquenessMatcher that could cause an error on postgres.
905
-
906
- * You can now pass an array to `ensure_exclusion_of` using `in_array`.
907
-
908
- * Allow testing of `:foreign_key` option for `has_one` relationships using the association matcher.
909
-
910
- * Fix bug where `ensure_length_of` would pass if the given string was too long.
911
-
912
- * `allow_blank` will now allow values such as: ' ', '\n', and '\r'.
913
-
914
- * Test outside values for `ensure_inclusion_of` when given an array.
915
-
916
- * Fix the output of the `set_the_flash` matcher.
917
-
918
- # v1.3.0
919
-
920
- * `validate_format_of` will accept `allow_blank(bool)` and `allow_nil(bool)`.
921
-
922
- * Prefer Test::Unit to MiniTest when loading integrations so that RubyMine is
923
- happy (#88).
924
-
925
- * `validates_uniqueness_of` will now create a record if one does not exist.
926
- Previously, users were required to create a record in the database before
927
- using this matcher.
928
-
929
- * Fix an edge case when where the matchers weren't loaded into Test::Unit when
930
- mixing RSpec and Test::Unit tests and also loading both the 'rspec-rails' gem
931
- and 'shoulda-matchers' gem from the same Gemfile group, namely [:test,
932
- :development].
933
-
934
- * `controller.should_not render_partial` now correctly matches `render partial: "partial"`.
935
-
936
- # v1.2.0
937
-
938
- * `ensure_inclusion_of` now has an `in_array` parameter:
939
- `ensure_inclusion_of(:attr).in_array(['foo', 'bar'])`. It cannot be used with
940
- the `.in_range` option. (vpereira)
941
-
942
- * `ensure_in_inclusion_of` with `in_array` will accept `allow_blank(bool)` and `allow_nil(false)`
943
-
944
- * Test against Rails 3.2.
945
-
946
- * Fix `ensure_length_of` to use all possible I18n error messages.
947
-
948
- * `have_db_index.unique(nil)` used to function exactly the same as
949
- `have_db_index` with no unique option. It now functions the same as
950
- `have_db_index.unique(false)`.
951
-
952
- * In 1.1.0, `have_sent_email` checked all emails to ensure they matched. It now
953
- checks that only one email matches, which restores 1.0.0 behavior.
954
-
955
- # v1.1.0
956
-
957
- * Add `only_integer` option to `validate_numericality_of`:
958
- `should validate_numericality_of(:attribute).only_integer`
959
-
960
- * Add a `query_the_database` matcher:
961
-
962
- `it { should query_the_database(4.times).when_calling(:complicated_method) }`
963
- `it { should query_the_database(4.times).or_less.when_calling(:complicated_method) }`
964
- `it { should_not query_the_database.when_calling(:complicated_method) }`
965
-
966
- * Database columns are now correctly checked for primality. E.G., this works
967
- now: `it { should have_db_column(:id).with_options(:primary => true) }`
968
-
969
- * The flash matcher can check specific flash keys using [], like so:
970
- `it { should set_the_flash[:alert].to("Password doesn't match") }`
971
-
972
- * The `have_sent_email` matcher can check `reply_to`:
973
- ` it { should have_sent_email.reply_to([user, other]) }`
974
-
975
- * Add `validates_confirmation_of` matcher:
976
- `it { should validate_confirmation_of(:password) }`
977
-
978
- * Add `serialize` matcher:
979
- `it { should serialize(:details).as(Hash).as_instance_of(Hash) }`
980
-
981
- * shoulda-matchers checks for all possible I18n keys, instead of just
982
- e.g. `activerecord.errors.messages.blank`
983
-
984
- * Add `accept_nested_attributes` matcher
985
-
986
- * Our very first dependency: ActiveSupport &gt;= 3.0.0