shoulda-matchers 3.1.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,76 +0,0 @@
1
- require 'unit_spec_helper'
2
-
3
- describe Shoulda::Matchers::ActionController::RenderTemplateMatcher, type: :controller do
4
- context 'a controller that renders a template' do
5
- it 'accepts rendering that template' do
6
- expect(controller_with_show).to render_template(:show)
7
- end
8
-
9
- it 'rejects rendering a different template' do
10
- expect(controller_with_show).not_to render_template(:index)
11
- end
12
-
13
- it 'accepts rendering that template in the given context' do
14
- expect(controller_with_show).to render_template(:show).in_context(self)
15
- end
16
-
17
- it 'rejects rendering a different template in the given context' do
18
- expect(controller_with_show).not_to render_template(:index).in_context(self)
19
- end
20
-
21
- def controller_with_show
22
- build_fake_response(action: 'show') { render }
23
- end
24
- end
25
-
26
- context 'a controller that renders a partial' do
27
- it 'accepts rendering that partial' do
28
- expect(controller_with_customer_partial).
29
- to render_template(partial: '_customer')
30
- end
31
-
32
- it 'rejects rendering a different template' do
33
- expect(controller_with_customer_partial).
34
- not_to render_template(partial: '_client')
35
- end
36
-
37
- it 'accepts rendering that template in the given context' do
38
- expect(controller_with_customer_partial).
39
- to render_template(partial: '_customer').in_context(self)
40
- end
41
-
42
- it 'rejects rendering a different template in the given context' do
43
- expect(controller_with_customer_partial).
44
- not_to render_template(partial: '_client').in_context(self)
45
- end
46
-
47
- def controller_with_customer_partial
48
- build_fake_response(partial: '_customer') { render partial: 'customer' }
49
- end
50
- end
51
-
52
- context 'a controller that does not render partials' do
53
- it 'accepts not rendering a partial' do
54
- controller = build_fake_response(action: 'show') { render }
55
-
56
- expect(controller).to render_template(partial: false)
57
- end
58
- end
59
-
60
- context 'a controller that renders a partial several times' do
61
- it 'accepts rendering that partial twice' do
62
- controller = build_fake_response(partial: '_customer') do
63
- render partial: 'customer', collection: [1,2]
64
- end
65
-
66
- expect(controller).to render_template(partial: '_customer', count: 2)
67
- end
68
- end
69
-
70
- context 'a controller that does not render a template' do
71
- it 'rejects rendering a template' do
72
- expect(build_fake_response { render nothing: true }).
73
- not_to render_template(:show)
74
- end
75
- end
76
- end
@@ -1,62 +0,0 @@
1
- require 'unit_spec_helper'
2
-
3
- describe Shoulda::Matchers::ActionController::RenderWithLayoutMatcher, type: :controller do
4
- include ActionController::TemplateAssertions
5
-
6
- context 'a controller that renders with a layout' do
7
- it 'accepts rendering with any layout' do
8
- expect(controller_with_wide_layout).to render_with_layout
9
- end
10
-
11
- it 'accepts rendering with that layout' do
12
- expect(controller_with_wide_layout).to render_with_layout(:wide)
13
- end
14
-
15
- it 'rejects rendering with another layout' do
16
- expect(controller_with_wide_layout).not_to render_with_layout(:other)
17
- end
18
-
19
- def controller_with_wide_layout
20
- create_view('layouts/wide.html.erb', 'some content, <%= yield %>')
21
- build_fake_response { render layout: 'wide' }
22
- end
23
- end
24
-
25
- context 'a controller that renders without a layout' do
26
-
27
- it 'rejects rendering with a layout' do
28
- controller_without_layout = build_fake_response { render layout: false }
29
-
30
- expect(controller_without_layout).not_to render_with_layout
31
- end
32
- end
33
-
34
- context 'a controller that renders a partial' do
35
- it 'rejects rendering with a layout' do
36
- controller_with_partial = build_fake_response { render partial: 'partial' }
37
-
38
- expect(controller_with_partial).not_to render_with_layout
39
- end
40
- end
41
-
42
- context 'given a context with layouts' do
43
- it 'accepts that layout in that context' do
44
- context = Object.new
45
- set_layout_in_context(context, 'happy')
46
-
47
- expect(controller_without_layout).
48
- to render_with_layout('happy').
49
- in_context(context)
50
- end
51
-
52
- def set_layout_in_context(context, layout)
53
- layouts = Hash.new(0)
54
- layouts[layout] = 1
55
- context.instance_variable_set('@_layouts', layouts)
56
- end
57
-
58
- def controller_without_layout
59
- build_fake_response { render layout: false }
60
- end
61
- end
62
- end
@@ -1,90 +0,0 @@
1
- require 'unit_spec_helper'
2
-
3
- describe Shoulda::Matchers::ActionController::RescueFromMatcher, type: :controller do
4
- context 'a controller that rescues from RuntimeError' do
5
- it 'asserts controller is setup with rescue_from' do
6
- expect(controller_with_rescue_from).to rescue_from RuntimeError
7
- end
8
-
9
- context 'with a handler method' do
10
- it 'asserts rescue_from can find the handler when it is public' do
11
- controller = controller_with_rescue_from_and_method(:public)
12
- check_rescue_with_method_for(controller)
13
- end
14
-
15
- it 'asserts rescue_from can find the handler when it is protected' do
16
- controller = controller_with_rescue_from_and_method(:protected)
17
- check_rescue_with_method_for(controller)
18
- end
19
-
20
- it 'asserts rescue_from can find the handler when it is private' do
21
- controller = controller_with_rescue_from_and_method(:private)
22
- check_rescue_with_method_for(controller)
23
- end
24
-
25
- it 'asserts rescue_from was not set up with incorrect handler method' do
26
- expect(controller_with_rescue_from_and_method).not_to rescue_from(RuntimeError).with(:other_method)
27
- end
28
-
29
- it 'asserts the controller responds to the handler method' do
30
- matcher = rescue_from(RuntimeError).with(:error_method)
31
- expect(matcher.matches?(controller_with_rescue_from_and_invalid_method)).to eq false
32
- expect(matcher.failure_message).to match(/does not respond to/)
33
- end
34
- end
35
-
36
- context 'without a handler method' do
37
- it 'the handler method is not included in the description' do
38
- matcher = rescue_from(RuntimeError)
39
- expect(matcher.matches?(controller_with_rescue_from)).to eq true
40
- expect(matcher.description).not_to match(/with #/)
41
- end
42
- end
43
- end
44
-
45
- context 'a controller that does not rescue from RuntimeError' do
46
- it 'asserts controller is not setup with rescue_from' do
47
- matcher = rescue_from RuntimeError
48
- expect(define_controller('RandomController')).not_to matcher
49
- expect(matcher.failure_message_when_negated).to match(/Did not expect \w+ to rescue from/)
50
- end
51
- end
52
-
53
- def check_rescue_with_method_for(controller)
54
- expect(controller).to rescue_from(RuntimeError).with(:error_method)
55
- end
56
-
57
- def controller_with_rescue_from
58
- define_controller 'RescueRuntimeError' do
59
- rescue_from(RuntimeError) {}
60
- end
61
- end
62
-
63
- def controller_with_rescue_from_and_invalid_method
64
- define_controller 'RescueRuntimeErrorWithMethod' do
65
- rescue_from RuntimeError, with: :error_method
66
- end
67
- end
68
-
69
- def controller_with_rescue_from_and_method(access = :public)
70
- controller = controller_with_rescue_from_and_invalid_method
71
- class << controller
72
- def error_method
73
- true
74
- end
75
- end
76
-
77
- case access
78
- when :protected
79
- class << controller
80
- protected :error_method
81
- end
82
- when :private
83
- class << controller
84
- private :error_method
85
- end
86
- end
87
-
88
- controller
89
- end
90
- end
@@ -1,31 +0,0 @@
1
- require 'unit_spec_helper'
2
-
3
- describe Shoulda::Matchers::ActionController::RespondWithMatcher, type: :controller do
4
- statuses = { success: 200, redirect: 301, missing: 404, error: 500,
5
- not_implemented: 501 }
6
-
7
- statuses.each do |human_name, numeric_code|
8
- context "a controller responding with #{human_name}" do
9
- it 'accepts responding with a numeric response code' do
10
- expect(controller_with_status(numeric_code)).to respond_with(numeric_code)
11
- end
12
-
13
- it 'accepts responding with a symbol response code' do
14
- expect(controller_with_status(numeric_code)).to respond_with(human_name)
15
- end
16
-
17
- it 'rejects responding with another status' do
18
- another_status = statuses.except(human_name).keys.first
19
-
20
- expect(controller_with_status(numeric_code)).
21
- not_to respond_with(another_status)
22
- end
23
- end
24
- end
25
-
26
- def controller_with_status(status)
27
- build_fake_response do
28
- render text: 'text', status: status
29
- end
30
- end
31
- end
@@ -1,330 +0,0 @@
1
- require 'unit_spec_helper'
2
-
3
- describe 'Shoulda::Matchers::ActionController::RouteMatcher', type: :controller do
4
- shared_examples_for 'tests involving expected route parts' do |args|
5
- include_controller_in_expected_route_options =
6
- args.fetch(:include_controller_in_expected_route_options)
7
-
8
- context 'when all parts of the expected route match an existing route' do
9
- it 'accepts' do
10
- define_route :get, '/', action: 'index'
11
-
12
- assert_accepts add_target_to(
13
- route(:get, '/'),
14
- build_expected_route_options(
15
- include_controller_in_expected_route_options,
16
- action: 'index'
17
- )
18
- )
19
- end
20
-
21
- if include_controller_in_expected_route_options
22
- context 'and the expected controller is specified as a symbol' do
23
- it 'accepts' do
24
- define_route :get, '/', action: 'index'
25
-
26
- assert_accepts add_target_to(
27
- route(:get, '/'),
28
- build_expected_route_options(
29
- include_controller_in_expected_route_options,
30
- action: 'index'
31
- )
32
- )
33
- end
34
- end
35
- end
36
-
37
- context 'and the expected action is specified as a symbol' do
38
- it 'accepts' do
39
- define_route :get, '/', action: 'index'
40
-
41
- assert_accepts add_target_to(
42
- route(:get, '/'),
43
- build_expected_route_options(
44
- include_controller_in_expected_route_options,
45
- action: :index
46
- )
47
- )
48
- end
49
- end
50
- end
51
-
52
- context 'when no parts of the expected route match an existing route' do
53
- it 'rejects' do
54
- assert_rejects add_target_to(
55
- route(:get, '/non_existent_route'),
56
- controller: 'no_controller',
57
- action: 'no_action'
58
- )
59
- end
60
- end
61
-
62
- context 'when all parts of the expected route but the method match an existing route' do
63
- it 'rejects' do
64
- define_route :post, '/', action: 'index'
65
-
66
- assert_rejects add_target_to(
67
- route(:get, '/'),
68
- build_expected_route_options(
69
- include_controller_in_expected_route_options,
70
- action: 'index'
71
- )
72
- )
73
- end
74
- end
75
-
76
- context 'when all parts of the expected route but the path match an existing route' do
77
- it 'rejects' do
78
- define_route :get, '/', action: 'index'
79
-
80
- assert_rejects add_target_to(
81
- route(:get, '/different_path'),
82
- build_expected_route_options(
83
- include_controller_in_expected_route_options,
84
- action: 'index'
85
- )
86
- )
87
- end
88
- end
89
-
90
- if include_controller_in_expected_route_options
91
- context 'when all parts of the expected route but the controller match an existing route' do
92
- it 'rejects' do
93
- define_route :get, '/', controller: 'another_controller', action: 'index'
94
-
95
- assert_rejects add_target_to(
96
- route(:get, '/'),
97
- build_expected_route_options(
98
- include_controller_in_expected_route_options,
99
- action: 'index'
100
- )
101
- )
102
- end
103
- end
104
- end
105
-
106
- context 'when all parts of the expected route but the action match an existing route' do
107
- it 'rejects' do
108
- define_route :get, '/', action: 'index'
109
-
110
- assert_rejects add_target_to(
111
- route(:get, '/'),
112
- build_expected_route_options(
113
- include_controller_in_expected_route_options,
114
- action: 'another_action'
115
- )
116
- )
117
- end
118
- end
119
- end
120
-
121
- shared_examples_for 'tests involving params' do
122
- context 'when the actual route has a param' do
123
- context 'and the expected params include that param' do
124
- it 'accepts' do
125
- define_route :get, "/#{controller_name}/:id", action: 'show'
126
-
127
- assert_accepts add_target_to(
128
- route(:get, "/#{controller_name}/1"),
129
- controller: controller_name,
130
- action: 'show',
131
- id: '1'
132
- )
133
- end
134
-
135
- context 'but its value was not specified as a string' do
136
- it 'accepts, treating it as a string' do
137
- define_route :get, "/#{controller_name}/:id", action: 'show'
138
-
139
- assert_accepts add_target_to(
140
- route(:get, "/#{controller_name}/1"),
141
- controller: controller_name,
142
- action: 'show',
143
- id: 1
144
- )
145
- end
146
- end
147
- end
148
-
149
- context 'and the expected params do not match the actual params' do
150
- it 'rejects' do
151
- define_route :get, "/#{controller_name}/:id", action: 'show'
152
-
153
- params = {
154
- controller: controller_name,
155
- action: 'show',
156
- some: 'other',
157
- params: 'here'
158
- }
159
- assert_rejects add_target_to(
160
- route(:get, "/#{controller_name}/:id"),
161
- params
162
- )
163
- end
164
- end
165
- end
166
-
167
- context 'when the actual route has a default param whose value is a symbol' do
168
- context 'and the expected params include a value for it' do
169
- context 'as a symbol' do
170
- it 'accepts' do
171
- define_route :post, "/#{controller_name}/(.:format)",
172
- action: 'create',
173
- defaults: { format: :json }
174
-
175
- assert_accepts add_target_to(
176
- route(:post, "/#{controller_name}"),
177
- controller: controller_name,
178
- action: 'create',
179
- format: :json
180
- )
181
- end
182
- end
183
-
184
- context 'as a string' do
185
- it 'accepts' do
186
- define_route :post, "/#{controller_name}/(.:format)",
187
- action: 'create',
188
- defaults: { format: :json }
189
-
190
- assert_accepts add_target_to(
191
- route(:post, "/#{controller_name}"),
192
- controller: controller_name,
193
- action: 'create',
194
- format: 'json'
195
- )
196
- end
197
- end
198
- end
199
- end
200
-
201
- context 'when the existing route has a glob segment' do
202
- context 'and a param is given which represents the segment' do
203
- it 'accepts' do
204
- define_route :get, "/#{controller_name}/*id", action: 'whatever'
205
-
206
- assert_accepts add_target_to(
207
- route(:get, "/#{controller_name}/foo/bar"),
208
- controller: controller_name,
209
- action: 'whatever',
210
- id: 'foo/bar'
211
- )
212
- end
213
- end
214
-
215
- context 'and no param is given which represents the segment' do
216
- it 'rejects' do
217
- define_route :get, "/#{controller_name}/*id", action: 'whatever'
218
-
219
- assert_rejects add_target_to(
220
- route(:get, "/#{controller_name}"),
221
- controller: controller_name,
222
- action: 'whatever'
223
- )
224
- end
225
- end
226
- end
227
- end
228
-
229
- shared_examples_for 'core tests' do
230
- context 'given a controller and action specified as individual options' do
231
- include_examples 'tests involving expected route parts',
232
- include_controller_in_expected_route_options: true
233
-
234
- include_examples 'tests involving params'
235
-
236
- def add_target_to(route_matcher, params)
237
- route_matcher.to(params)
238
- end
239
- end
240
-
241
- context 'given a controller and action joined together in a string' do
242
- include_examples 'tests involving expected route parts',
243
- include_controller_in_expected_route_options: true
244
-
245
- include_examples 'tests involving params'
246
-
247
- def add_target_to(route_matcher, args)
248
- controller = args.fetch(:controller)
249
- action = args.fetch(:action)
250
- route_matcher.to("#{controller}##{action}", args)
251
- end
252
- end
253
-
254
- context 'given just an action' do
255
- include_examples 'tests involving expected route parts',
256
- include_controller_in_expected_route_options: false
257
-
258
- include_examples 'tests involving params'
259
-
260
- def add_target_to(route_matcher, params)
261
- route_matcher.to(params)
262
- end
263
- end
264
- end
265
-
266
- before do
267
- setup_rails_controller_test(controller_class)
268
- end
269
-
270
- context 'given a controller that is not namespaced' do
271
- include_examples 'core tests'
272
-
273
- def controller_class_name
274
- 'ExamplesController'
275
- end
276
- end
277
-
278
- context 'given a controller that is namespaced' do
279
- def define_controller_under_test
280
- define_module('Admin')
281
- super
282
- end
283
-
284
- include_examples 'core tests'
285
-
286
- def controller_class_name
287
- 'Admin::ExamplesController'
288
- end
289
- end
290
-
291
- let(:controller_class) do
292
- define_controller_under_test
293
- end
294
-
295
- def define_controller_under_test
296
- define_controller(controller_class_name)
297
- end
298
-
299
- def controller_name
300
- controller_class_name.sub(/Controller$/, '').underscore
301
- end
302
-
303
- def define_route(method, path, args)
304
- action = args.fetch(:action)
305
- controller = args.fetch(:controller) { controller_name }
306
- define_routes do
307
- public_send(
308
- method,
309
- path,
310
- args.merge(controller: controller, action: action)
311
- )
312
- end
313
- end
314
-
315
- def build_expected_route_options(include_controller_in_expected_route_options, default_options)
316
- default_options.dup.tap do |options|
317
- if include_controller_in_expected_route_options
318
- options[:controller] = controller_name
319
- end
320
- end
321
- end
322
-
323
- def assert_accepts(matcher)
324
- expect(controller).to matcher
325
- end
326
-
327
- def assert_rejects(matcher)
328
- expect(controller).not_to matcher
329
- end
330
- end
@@ -1,30 +0,0 @@
1
- require 'unit_spec_helper'
2
-
3
- describe Shoulda::Matchers::ActionController::RouteParams, type: :controller do
4
- describe "#normalize" do
5
- context "when the route parameters is a hash" do
6
- it "stringifies the values in the hash" do
7
- expect(build_route_params(controller: :examples, action: 'example', id: '1').normalize).
8
- to eq({ controller: "examples", action: "example", id: "1" })
9
- end
10
- end
11
-
12
- context "when the route parameters is a string and a hash" do
13
- it "produces a hash of route parameters" do
14
- expect(build_route_params("examples#example", id: '1').normalize).
15
- to eq({ controller: "examples", action: "example", id: "1" })
16
- end
17
- end
18
-
19
- context "when the route params is a string" do
20
- it "produces a hash of route params" do
21
- expect(build_route_params("examples#index").normalize).
22
- to eq({ controller: "examples", action: "index"})
23
- end
24
- end
25
- end
26
-
27
- def build_route_params(*params)
28
- Shoulda::Matchers::ActionController::RouteParams.new(params)
29
- end
30
- end
@@ -1,67 +0,0 @@
1
- require 'unit_spec_helper'
2
-
3
- describe Shoulda::Matchers::ActionController::SetFlashMatcher, type: :controller do
4
- it_behaves_like 'set session or flash matcher' do
5
- def store_name
6
- 'flash'
7
- end
8
-
9
- def set_store
10
- set_flash
11
- end
12
-
13
- def store_within(controller)
14
- controller.flash
15
- end
16
- end
17
-
18
- it_behaves_like 'set session or flash matcher' do
19
- def store_name
20
- 'flash.now'
21
- end
22
-
23
- def set_store
24
- set_flash.now
25
- end
26
-
27
- def store_within(controller)
28
- controller.flash.now
29
- end
30
- end
31
-
32
- context 'when the controller sets both flash and flash.now' do
33
- it 'does not mix flash and flash.now' do
34
- controller = build_fake_response do
35
- flash['key for flash'] = 'value for flash'
36
- flash.now['key for flash.now'] = 'value for flash.now'
37
- end
38
-
39
- expect(controller).not_to set_flash['key for flash.now']
40
- expect(controller).not_to set_flash.now['key for flash']
41
- end
42
- end
43
-
44
- context 'when the now qualifier is called after the key is set' do
45
- it 'raises a QualifierOrderError' do
46
- controller = build_fake_response
47
-
48
- usage = lambda do
49
- expect(controller).to set_flash['any key'].now
50
- end
51
-
52
- expect(&usage).to raise_error(described_class::QualifierOrderError)
53
- end
54
- end
55
-
56
- context 'when the now qualifier is called after the to qualifier' do
57
- it 'raises a QualifierOrderError' do
58
- controller = build_fake_response
59
-
60
- usage = lambda do
61
- expect(controller).to set_flash.to('any value').now
62
- end
63
-
64
- expect(&usage).to raise_error(described_class::QualifierOrderError)
65
- end
66
- end
67
- end