shoulda-matchers 2.8.0 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/.hound_config/ruby.yml +7 -0
  3. data/.travis.yml +11 -54
  4. data/Appraisals +45 -100
  5. data/CONTRIBUTING.md +51 -7
  6. data/Gemfile +7 -19
  7. data/Gemfile.lock +60 -134
  8. data/Guardfile +5 -0
  9. data/NEWS.md +203 -0
  10. data/README.md +95 -50
  11. data/Rakefile +1 -0
  12. data/doc_config/yard/templates/default/layout/html/setup.rb +1 -1
  13. data/gemfiles/4.0.0.gemfile +10 -7
  14. data/gemfiles/4.0.0.gemfile.lock +103 -79
  15. data/gemfiles/4.0.1.gemfile +10 -7
  16. data/gemfiles/4.0.1.gemfile.lock +109 -83
  17. data/gemfiles/4.1.gemfile +10 -7
  18. data/gemfiles/4.1.gemfile.lock +109 -85
  19. data/gemfiles/4.2.gemfile +10 -9
  20. data/gemfiles/4.2.gemfile.lock +86 -78
  21. data/lib/shoulda/matchers.rb +13 -18
  22. data/lib/shoulda/matchers/action_controller.rb +4 -1
  23. data/lib/shoulda/matchers/action_controller/flash_store.rb +95 -0
  24. data/lib/shoulda/matchers/action_controller/{strong_parameters_matcher.rb → permit_matcher.rb} +147 -30
  25. data/lib/shoulda/matchers/action_controller/redirect_to_matcher.rb +1 -1
  26. data/lib/shoulda/matchers/action_controller/render_template_matcher.rb +1 -1
  27. data/lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb +1 -1
  28. data/lib/shoulda/matchers/action_controller/rescue_from_matcher.rb +1 -1
  29. data/lib/shoulda/matchers/action_controller/route_matcher.rb +5 -1
  30. data/lib/shoulda/matchers/action_controller/route_params.rb +15 -6
  31. data/lib/shoulda/matchers/action_controller/session_store.rb +34 -0
  32. data/lib/shoulda/matchers/action_controller/set_flash_matcher.rb +30 -136
  33. data/lib/shoulda/matchers/action_controller/set_session_matcher.rb +28 -109
  34. data/lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb +103 -0
  35. data/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb +1 -12
  36. data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +79 -10
  37. data/lib/shoulda/matchers/active_model/numericality_matchers/numeric_type_matcher.rb +10 -0
  38. data/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +21 -0
  39. data/lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb +24 -0
  40. data/lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb +22 -5
  41. data/lib/shoulda/matchers/active_model/validate_exclusion_of_matcher.rb +29 -10
  42. data/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +27 -10
  43. data/lib/shoulda/matchers/active_model/validate_length_of_matcher.rb +27 -12
  44. data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +56 -20
  45. data/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb +3 -11
  46. data/lib/shoulda/matchers/active_model/validation_message_finder.rb +65 -0
  47. data/lib/shoulda/matchers/active_record/association_matcher.rb +40 -6
  48. data/lib/shoulda/matchers/active_record/association_matchers/join_table_matcher.rb +21 -7
  49. data/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +11 -40
  50. data/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +1 -1
  51. data/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb +2 -6
  52. data/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +137 -22
  53. data/lib/shoulda/matchers/configuration.rb +20 -0
  54. data/lib/shoulda/matchers/doublespeak.rb +11 -1
  55. data/lib/shoulda/matchers/doublespeak/double.rb +29 -11
  56. data/lib/shoulda/matchers/doublespeak/double_collection.rb +4 -3
  57. data/lib/shoulda/matchers/doublespeak/method_call.rb +35 -0
  58. data/lib/shoulda/matchers/doublespeak/object_double.rb +7 -2
  59. data/lib/shoulda/matchers/doublespeak/proxy_implementation.rb +4 -3
  60. data/lib/shoulda/matchers/doublespeak/stub_implementation.rb +3 -3
  61. data/lib/shoulda/matchers/doublespeak/world.rb +21 -1
  62. data/lib/shoulda/matchers/integrations.rb +43 -0
  63. data/lib/shoulda/matchers/integrations/configuration.rb +68 -0
  64. data/lib/shoulda/matchers/integrations/configuration_error.rb +9 -0
  65. data/lib/shoulda/matchers/integrations/inclusion.rb +20 -0
  66. data/lib/shoulda/matchers/integrations/libraries.rb +15 -0
  67. data/lib/shoulda/matchers/integrations/libraries/action_controller.rb +31 -0
  68. data/lib/shoulda/matchers/integrations/libraries/active_model.rb +26 -0
  69. data/lib/shoulda/matchers/integrations/libraries/active_record.rb +26 -0
  70. data/lib/shoulda/matchers/integrations/libraries/missing_library.rb +19 -0
  71. data/lib/shoulda/matchers/integrations/libraries/rails.rb +30 -0
  72. data/lib/shoulda/matchers/integrations/rails.rb +12 -0
  73. data/lib/shoulda/matchers/integrations/registry.rb +28 -0
  74. data/lib/shoulda/matchers/integrations/test_frameworks.rb +16 -0
  75. data/lib/shoulda/matchers/integrations/test_frameworks/active_support_test_case.rb +37 -0
  76. data/lib/shoulda/matchers/integrations/test_frameworks/minitest_4.rb +36 -0
  77. data/lib/shoulda/matchers/integrations/test_frameworks/minitest_5.rb +37 -0
  78. data/lib/shoulda/matchers/integrations/test_frameworks/missing_test_framework.rb +40 -0
  79. data/lib/shoulda/matchers/integrations/test_frameworks/rspec.rb +29 -0
  80. data/lib/shoulda/matchers/integrations/test_frameworks/test_unit.rb +36 -0
  81. data/lib/shoulda/matchers/rails_shim.rb +0 -40
  82. data/lib/shoulda/matchers/version.rb +1 -1
  83. data/script/SUPPORTED_VERSIONS +1 -1
  84. data/script/update_gems_in_all_appraisals +14 -0
  85. data/shoulda-matchers.gemspec +2 -2
  86. data/spec/acceptance/active_model_integration_spec.rb +4 -1
  87. data/spec/acceptance/independent_matchers_spec.rb +6 -6
  88. data/spec/acceptance/multiple_libraries_integration_spec.rb +52 -0
  89. data/spec/acceptance/rails_integration_spec.rb +15 -5
  90. data/spec/acceptance_spec_helper.rb +8 -0
  91. data/spec/doublespeak_spec_helper.rb +14 -0
  92. data/spec/support/acceptance/adds_shoulda_matchers_to_project.rb +110 -0
  93. data/spec/support/acceptance/helpers.rb +2 -0
  94. data/spec/support/acceptance/helpers/base_helpers.rb +6 -1
  95. data/spec/support/acceptance/helpers/command_helpers.rb +6 -2
  96. data/spec/support/acceptance/helpers/minitest_helpers.rb +0 -8
  97. data/spec/support/acceptance/helpers/n_unit_helpers.rb +25 -0
  98. data/spec/support/acceptance/helpers/rspec_helpers.rb +2 -0
  99. data/spec/support/acceptance/helpers/step_helpers.rb +13 -19
  100. data/spec/support/acceptance/matchers/have_output.rb +1 -1
  101. data/spec/support/tests/bundle.rb +1 -1
  102. data/spec/support/tests/command_runner.rb +25 -13
  103. data/spec/support/tests/current_bundle.rb +47 -0
  104. data/spec/support/tests/database.rb +28 -0
  105. data/spec/support/tests/database_adapters/postgresql.rb +25 -0
  106. data/spec/support/tests/database_adapters/sqlite3.rb +26 -0
  107. data/spec/support/tests/database_configuration.rb +33 -0
  108. data/spec/support/tests/database_configuration_registry.rb +28 -0
  109. data/spec/support/tests/filesystem.rb +25 -2
  110. data/spec/support/unit/helpers/active_record_versions.rb +12 -0
  111. data/spec/support/unit/helpers/class_builder.rb +6 -2
  112. data/spec/support/unit/helpers/column_type_helpers.rb +26 -0
  113. data/spec/support/unit/helpers/controller_builder.rb +0 -28
  114. data/spec/support/unit/helpers/database_helpers.rb +18 -0
  115. data/spec/support/unit/helpers/model_builder.rb +38 -6
  116. data/spec/support/unit/helpers/rails_versions.rb +2 -2
  117. data/spec/support/unit/matchers/fail_with_message_including_matcher.rb +9 -8
  118. data/spec/support/unit/matchers/fail_with_message_matcher.rb +1 -1
  119. data/spec/support/unit/rails_application.rb +29 -13
  120. data/spec/support/unit/record_validating_confirmation_builder.rb +1 -2
  121. data/spec/support/unit/shared_examples/set_session_or_flash.rb +355 -0
  122. data/spec/unit/shoulda/matchers/action_controller/permit_matcher_spec.rb +433 -0
  123. data/spec/unit/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb +1 -5
  124. data/spec/unit/shoulda/matchers/action_controller/route_matcher_spec.rb +37 -0
  125. data/spec/unit/shoulda/matchers/action_controller/set_flash_matcher_spec.rb +23 -147
  126. data/spec/unit/shoulda/matchers/action_controller/set_session_matcher_spec.rb +8 -285
  127. data/spec/unit/shoulda/matchers/action_controller/set_session_or_flash_matcher_spec.rb +562 -0
  128. data/spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb +81 -14
  129. data/spec/unit/shoulda/matchers/active_model/disallow_value_matcher_spec.rb +16 -8
  130. data/spec/unit/shoulda/matchers/active_model/numericality_matchers/comparison_matcher_spec.rb +101 -9
  131. data/spec/unit/shoulda/matchers/active_model/numericality_matchers/even_number_matcher_spec.rb +39 -1
  132. data/spec/unit/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher_spec.rb +39 -1
  133. data/spec/unit/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher_spec.rb +39 -0
  134. data/spec/unit/shoulda/matchers/active_model/validate_exclusion_of_matcher_spec.rb +0 -17
  135. data/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb +0 -17
  136. data/spec/unit/shoulda/matchers/active_model/validate_length_of_matcher_spec.rb +0 -17
  137. data/spec/unit/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb +838 -271
  138. data/spec/unit/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb +0 -19
  139. data/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb +93 -0
  140. data/spec/unit/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb +3 -3
  141. data/spec/unit/shoulda/matchers/active_record/define_enum_for_matcher_spec.rb +25 -0
  142. data/spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb +905 -0
  143. data/spec/unit/shoulda/matchers/doublespeak/double_collection_spec.rb +17 -11
  144. data/spec/unit/shoulda/matchers/doublespeak/double_implementation_registry_spec.rb +1 -1
  145. data/spec/unit/shoulda/matchers/doublespeak/double_spec.rb +144 -43
  146. data/spec/unit/shoulda/matchers/doublespeak/object_double_spec.rb +1 -1
  147. data/spec/unit/shoulda/matchers/doublespeak/proxy_implementation_spec.rb +36 -11
  148. data/spec/unit/shoulda/matchers/doublespeak/stub_implementation_spec.rb +29 -16
  149. data/spec/unit/shoulda/matchers/doublespeak/world_spec.rb +8 -5
  150. data/spec/unit/shoulda/matchers/doublespeak_spec.rb +1 -1
  151. data/spec/unit_spec_helper.rb +15 -14
  152. data/spec/warnings_spy.rb +1 -1
  153. metadata +68 -29
  154. data/docs.watchr +0 -5
  155. data/gemfiles/3.0.gemfile +0 -26
  156. data/gemfiles/3.0.gemfile.lock +0 -173
  157. data/gemfiles/3.1.gemfile +0 -32
  158. data/gemfiles/3.1.gemfile.lock +0 -212
  159. data/gemfiles/3.1_1.9.2.gemfile +0 -32
  160. data/gemfiles/3.1_1.9.2.gemfile.lock +0 -212
  161. data/gemfiles/3.2.gemfile +0 -33
  162. data/gemfiles/3.2.gemfile.lock +0 -212
  163. data/gemfiles/3.2_1.9.2.gemfile +0 -31
  164. data/gemfiles/3.2_1.9.2.gemfile.lock +0 -207
  165. data/lib/shoulda/matchers/assertion_error.rb +0 -27
  166. data/lib/shoulda/matchers/doublespeak/structs.rb +0 -10
  167. data/lib/shoulda/matchers/integrations/nunit_test_case_detection.rb +0 -39
  168. data/lib/shoulda/matchers/integrations/rspec.rb +0 -19
  169. data/lib/shoulda/matchers/integrations/test_unit.rb +0 -34
  170. data/spec/unit/shoulda/matchers/action_controller/strong_parameters_matcher_spec.rb +0 -331
  171. data/spec/unit/shoulda/matchers/active_model/validate_uniqueness_of_matcher_spec.rb +0 -564
@@ -0,0 +1,5 @@
1
+ guard 'yard' do
2
+ watch('README.md')
3
+ watch(%r{doc_config/yard/.+})
4
+ watch(%r{lib/[^/]+\.rb})
5
+ end
data/NEWS.md CHANGED
@@ -1,3 +1,206 @@
1
+ # HEAD
2
+
3
+ ### Backward-incompatible changes
4
+
5
+ * We've dropped support for Rails 3.x, Ruby 1.9.2, and Ruby 1.9.3, and RSpec 2.
6
+ All of these things have been end-of-lifed. This doesn't mean that the gem
7
+ will stop working immediately, but we won't accept any pull requests to fix
8
+ any compatibility issues, so you're encouraged to upgrade.
9
+ ([a4045a1], [b7fe87a])
10
+
11
+ * The gem no longer detects the test framework you're using or mixes itself into
12
+ that framework automatically. [History][no-auto-integration-1] has
13
+ [shown][no-auto-integration-2] that performing any kind of detection is prone
14
+ to bugs and more complicated than it should be.
15
+
16
+ Here are the updated instructions:
17
+
18
+ * You no longer need to say `require: false` in your Gemfile; you can
19
+ include the gem as normal.
20
+ * You'll need to add the following somewhere in your `rails_helper` (for
21
+ RSpec) or `test_helper` (for Minitest / Test::Unit):
22
+
23
+ ``` ruby
24
+ Shoulda::Matchers.configure do |config|
25
+ config.integrate do |with|
26
+ # Choose a test framework:
27
+ with.test_framework :rspec
28
+ with.test_framework :minitest
29
+ with.test_framework :minitest_4
30
+ with.test_framework :test_unit
31
+
32
+ # Choose one or more libraries:
33
+ with.library :active_record
34
+ with.library :active_model
35
+ with.library :action_controller
36
+ # Or, choose the following (which implies all of the above):
37
+ with.library :rails
38
+ end
39
+ end
40
+ ```
41
+
42
+ ([1900071])
43
+
44
+ * There are two changes to `allow_value`:
45
+
46
+ * The negative form of the matcher has been changed so that instead of
47
+ asserting that any of the given values is an invalid value (allowing good
48
+ values to pass through), assert that *all* values are invalid values
49
+ (allowing good values not to pass through). This means that this test which
50
+ formerly passed will now fail:
51
+
52
+ expect(record).not_to allow_value('good value', *bad_values)
53
+
54
+ ([19ce8a6])
55
+
56
+ * The matcher may raise an error if the attribute in question contains
57
+ custom logic to ignore certain values, resulting in a discrepancy between
58
+ the value you provide and the value that the attribute is actually set to.
59
+ Specifically, if the attribute cannot be changed from a non-nil value to a
60
+ nil value, or vice versa, then you'll get a CouldNotSetAttributeError. The
61
+ current behavior (which is to permit this) is misleading, as the test that
62
+ you're writing under the hood by using `allow_value` could be different from
63
+ the test that actually ends up getting run. ([eaaa2d8])
64
+
65
+ * `validate_uniqueness_of` is now properly case-insensitive by default, to match
66
+ the default behavior of the validation itself. This is a backward-incompatible
67
+ change because this test which incorrectly passed before will now fail:
68
+
69
+ ``` ruby
70
+ class Product < ActiveRecord::Base
71
+ validates_uniqueness_of :name, case_sensitive: false
72
+ end
73
+
74
+ describe Product do
75
+ it { is_expected.to validate_uniqueness_of(:name) }
76
+ end
77
+ ```
78
+
79
+ ([57a1922])
80
+
81
+ * `ensure_inclusion_of`, `ensure_exclusion_of`, and `ensure_length_of` have been
82
+ removed in favor of their `validate_*` counterparts. ([55c8d09])
83
+
84
+ * `set_the_flash` and `set_session` have been changed to more closely align with
85
+ each other:
86
+ * `set_the_flash` has been removed in favor of `set_flash`. ([801f2c7])
87
+ * `set_session('foo')` is no longer valid syntax, please use
88
+ `set_session['foo']` instead. ([535fe05])
89
+ * `set_session['key'].to(nil)` will no longer pass when the key in question
90
+ has not been set yet. ([535fe05])
91
+
92
+ * Change behavior of `validate_uniqueness_of` when the matcher is not
93
+ qualified with any scopes, but your validation is. Previously the following
94
+ test would pass when it now fails:
95
+
96
+ ``` ruby
97
+ class Post < ActiveRecord::Base
98
+ validate :slug, uniqueness: { scope: :user_id }
99
+ end
100
+
101
+ describe Post do
102
+ it { should validate_uniqueness_of(:slug) }
103
+ end
104
+ ```
105
+
106
+ ([6ac7b81])
107
+
108
+ [no-auto-integration-1]: https://github.com/freerange/mocha/commit/049080c673ee3f76e76adc1e1a6122c7869f1648
109
+ [no-auto-integration-2]: https://github.com/rr/rr/issues/29
110
+ [1900071]: https://github.com/thoughtbot/shoulda-matchers/commit/190007155e0676aae84d08d8ed8eed3beebc3a06
111
+ [b7fe87a]: https://github.com/thoughtbot/shoulda-matchers/commit/b7fe87ae915f6b1f99d64e847fea536ad0f78024
112
+ [a4045a1]: https://github.com/thoughtbot/shoulda-matchers/commit/a4045a1f9bc454e618a7c55960942eb030f02fdd
113
+ [57a1922]: https://github.com/thoughtbot/shoulda-matchers/commit/57a19228b6a85f12ba7a79a26dae5869c1499c6d
114
+ [19ce8a6]: https://github.com/thoughtbot/shoulda-matchers/commit/19c38a642a2ae1316ef12540a0185cd026901e74
115
+ [eaaa2d8]: https://github.com/thoughtbot/shoulda-matchers/commit/eaaa2d83e5cd31a3ca0a1aaa65441ea1a4fffa49
116
+ [55c8d09]: https://github.com/thoughtbot/shoulda-matchers/commit/55c8d09bf2af886540924efa83c3b518d926a770
117
+ [801f2c7]: https://github.com/thoughtbot/shoulda-matchers/commit/801f2c7c1eab3b2053244485c9800f850959cfef
118
+ [535fe05]: https://github.com/thoughtbot/shoulda-matchers/commit/535fe05be8686fdafd8b22f2ed5c4192bd565d50
119
+ [eaaa2d8]: https://github.com/thoughtbot/shoulda-matchers/commit/eaaa2d83e5cd31a3ca0a1aaa65441ea1a4fffa49
120
+ [6ac7b81]: https://github.com/thoughtbot/shoulda-matchers/commit/6ac7b8158cfba3b518eb3da3c24345e4473b416f
121
+
122
+ ### Bug fixes
123
+
124
+ * So far the tests for the gem have been running against only SQLite. Now they
125
+ run against PostgreSQL, too. As a result we were able to fix some
126
+ Postgres-related bugs, specifically around `validate_uniqueness_of`:
127
+
128
+ * When scoped to a UUID column that ends in an "f", the matcher is able to
129
+ generate a proper "next" value without erroring. ([#402], [#587], [#662])
130
+
131
+ * Support scopes that are PostgreSQL array columns. Please note that this is
132
+ only supported for Rails 4.2 and greater, as versions before this cannot
133
+ handle array columns correctly, particularly in conjunction with the
134
+ uniqueness validator. ([#554])
135
+
136
+ * Fix so that when scoped to a text column and the scope is set to nil before
137
+ running it through the matcher, the matcher does not fail. ([#521], [#607])
138
+
139
+ * Fix `define_enum_for` so that it actually tests that the attribute is present
140
+ in the list of defined enums, as you could fool it by merely defining a class
141
+ method that was the pluralized version of the attribute name. In the same
142
+ vein, passing a pluralized version of the attribute name to `define_enum_for`
143
+ would erroneously pass, and now it fails. ([#641])
144
+
145
+ * Fix `permit` so that it does not break the functionality of
146
+ ActionController::Parameters#require. ([#648], [#675])
147
+
148
+ * Fix `validate_uniqueness_of` + `scoped_to` so that it does not raise an error
149
+ if a record exists where the scoped attribute is nil. ([#677])
150
+
151
+ * Fix `route` matcher so if your route includes a default `format`, you can
152
+ specify this as a symbol or string. ([#693])
153
+
154
+ * Fix `validate_uniqueness_of` so that it allows you to test against scoped
155
+ attributes that are boolean columns. ([#457], [#694])
156
+
157
+ * Fix failure message for `validate_numericality_of` as it sometimes didn't
158
+ provide the reason for failure. ([#699])
159
+
160
+ ### Features
161
+
162
+ * Add `on` qualifier to `permit`. This allows you to make an assertion that
163
+ a restriction was placed on a slice of the `params` hash and not the entire
164
+ `params` hash. Although we don't require you to use this qualifier, we do
165
+ recommend it, as it's a more precise check. ([#675])
166
+
167
+ * Add `strict` qualifier to `validate_numericality_of`. ([#620])
168
+
169
+ * Add `on` qualifier to `validate_numericality_of`. ([9748869]; h/t [#356],
170
+ [#358])
171
+
172
+ * Add `join_table` qualifier to `have_and_belong_to_many`. ([#556])
173
+
174
+ * `allow_values` is now an alias for `allow_value`. This makes more sense when
175
+ checking against multiple values:
176
+
177
+ ``` ruby
178
+ it { should allow_values('this', 'and', 'that') }
179
+ ```
180
+
181
+ ([#692])
182
+
183
+ [9748869]: https://github.com/thoughtbot/shoulda-matchers/commit/97488690910520ed8e1f2e164b1982eff5ef1f19
184
+ [#402]: https://github.com/thoughtbot/shoulda-matchers/pull/402
185
+ [#587]: https://github.com/thoughtbot/shoulda-matchers/pull/587
186
+ [#662]: https://github.com/thoughtbot/shoulda-matchers/pull/662
187
+ [#554]: https://github.com/thoughtbot/shoulda-matchers/pull/554
188
+ [#641]: https://github.com/thoughtbot/shoulda-matchers/pull/641
189
+ [#521]: https://github.com/thoughtbot/shoulda-matchers/pull/521
190
+ [#607]: https://github.com/thoughtbot/shoulda-matchers/pull/607
191
+ [#648]: https://github.com/thoughtbot/shoulda-matchers/pull/648
192
+ [#675]: https://github.com/thoughtbot/shoulda-matchers/pull/675
193
+ [#677]: https://github.com/thoughtbot/shoulda-matchers/pull/677
194
+ [#620]: https://github.com/thoughtbot/shoulda-matchers/pull/620
195
+ [#693]: https://github.com/thoughtbot/shoulda-matchers/pull/693
196
+ [#356]: https://github.com/thoughtbot/shoulda-matchers/pull/356
197
+ [#358]: https://github.com/thoughtbot/shoulda-matchers/pull/358
198
+ [#556]: https://github.com/thoughtbot/shoulda-matchers/pull/556
199
+ [#457]: https://github.com/thoughtbot/shoulda-matchers/pull/457
200
+ [#694]: https://github.com/thoughtbot/shoulda-matchers/pull/694
201
+ [#692]: https://github.com/thoughtbot/shoulda-matchers/pull/692
202
+ [#699]: https://github.com/thoughtbot/shoulda-matchers/pull/699
203
+
1
204
  # 2.8.0
2
205
 
3
206
  ### Deprecations
data/README.md CHANGED
@@ -1,12 +1,17 @@
1
- # shoulda-matchers [![Gem Version][version-badge]][rubygems] [![Build Status][travis-badge]][travis] ![Downloads][downloads-badge]
1
+ # Shoulda Matchers [![Gem Version][version-badge]][rubygems] [![Build Status][travis-badge]][travis] ![Downloads][downloads-badge]
2
2
 
3
- [Official Documentation][rubydocs]
4
-
5
- shoulda-matchers provides Test::Unit- and RSpec-compatible one-liners that test
3
+ Shoulda Matchers provides RSpec- and Minitest-compatible one-liners that test
6
4
  common Rails functionality. These tests would otherwise be much longer, more
7
5
  complex, and error-prone.
8
6
 
9
- ### ActiveModel Matchers
7
+ [View the official documentation for the latest version (2.8.0).][rubydocs]
8
+
9
+ **Heads up! This is the README for the master branch. [You might be more
10
+ interested in the README for 2.8.0 instead.][2.8.0-README]**
11
+
12
+ ----
13
+
14
+ ### ActiveModel matchers
10
15
 
11
16
  * **[allow_mass_assignment_of](lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb)**
12
17
  tests usage of Rails 3's `attr_accessible` and `attr_protected` macros.
@@ -27,7 +32,7 @@ complex, and error-prone.
27
32
  * **[validate_presence_of](lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb)**
28
33
  tests usage of `validates_presence_of`.
29
34
 
30
- ### ActiveRecord Matchers
35
+ ### ActiveRecord matchers
31
36
 
32
37
  * **[accept_nested_attributes_for](lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb)**
33
38
  tests usage of the `accepts_nested_attributes_for` macro.
@@ -52,10 +57,12 @@ complex, and error-prone.
52
57
  * **[validate_uniqueness_of](lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb)**
53
58
  tests usage of `validates_uniqueness_of`.
54
59
 
55
- ### ActionController Matchers
60
+ ### ActionController matchers
56
61
 
57
62
  * **[filter_param](lib/shoulda/matchers/action_controller/filter_param_matcher.rb)**
58
63
  tests parameter filtering configuration.
64
+ * **[permit](lib/shoulda/matchers/action_controller/permit_matcher.rb)** tests
65
+ that an action places a restriction on the `params` hash.
59
66
  * **[redirect_to](lib/shoulda/matchers/action_controller/redirect_to_matcher.rb)**
60
67
  tests that an action redirects to a certain location.
61
68
  * **[render_template](lib/shoulda/matchers/action_controller/render_template_matcher.rb)**
@@ -72,17 +79,17 @@ complex, and error-prone.
72
79
  makes assertions on the `session` hash.
73
80
  * **[set_flash](lib/shoulda/matchers/action_controller/set_flash_matcher.rb)**
74
81
  makes assertions on the `flash` hash.
75
- * **[use_after_action](lib/shoulda/matchers/action_controller/use_after_action.rb)**
82
+ * **[use_after_action](lib/shoulda/matchers/action_controller/callback_matcher.rb#L79)**
76
83
  tests that a `after_action` callback is defined in your controller. (Aliased
77
84
  as *use_after_filter*.)
78
- * **[use_around_action](lib/shoulda/matchers/action_controller/use_around_action.rb)**
85
+ * **[use_around_action](lib/shoulda/matchers/action_controller/callback_matcher.rb#L129)**
79
86
  tests that a `around_action` callback is defined in your controller. (Aliased
80
87
  as *use_around_filter*.)
81
- * **[use_before_action](lib/shoulda/matchers/action_controller/use_before_action.rb)**
88
+ * **[use_before_action](lib/shoulda/matchers/action_controller/callback_matcher.rb#L54)**
82
89
  tests that a `before_action` callback is defined in your controller. (Aliased
83
90
  as *use_before_filter*.)
84
91
 
85
- ### Independent Matchers
92
+ ### Independent matchers
86
93
 
87
94
  * **[delegate_method](lib/shoulda/matchers/independent/delegate_method_matcher.rb)**
88
95
  tests that an object forwards messages to other, internal objects by way of
@@ -92,27 +99,30 @@ complex, and error-prone.
92
99
 
93
100
  ### RSpec
94
101
 
95
- Include the gem in your Gemfile:
102
+ Include `shoulda-matchers` in your Gemfile:
96
103
 
97
104
  ``` ruby
98
105
  group :test do
99
- gem 'shoulda-matchers', require: false
106
+ gem 'shoulda-matchers'
100
107
  end
101
108
  ```
102
109
 
103
- Then require the gem following rspec-rails in your rails_helper (or spec_helper
104
- if you're using RSpec 2.x):
110
+ [Then, configure the gem to integrate with RSpec](#configuration).
111
+
112
+ Now you can use matchers in your tests. For instance a model test might look
113
+ like this:
105
114
 
106
115
  ``` ruby
107
- require 'rspec/rails'
108
- require 'shoulda/matchers'
116
+ describe Person do
117
+ it { should validate_presence_of(:name) }
118
+ end
109
119
  ```
110
120
 
111
- ### Test::Unit
121
+ ### Minitest / Test::Unit
112
122
 
113
- shoulda-matchers was originally a component of [Shoulda][shoulda], a meta-gem
114
- that also provides `should` and `context` syntax via
115
- [shoulda-context][shoulda-context]. For this reason you'll want to include this
123
+ Shoulda Matchers was originally a component of [Shoulda][shoulda], a gem that
124
+ also provides `should` and `context` syntax via
125
+ [`shoulda-context`][shoulda-context]. For this reason you'll want to include this
116
126
  gem in your Gemfile instead:
117
127
 
118
128
  ```ruby
@@ -121,31 +131,48 @@ group :test do
121
131
  end
122
132
  ```
123
133
 
124
- ### Non-Rails apps
125
-
126
- Once it is loaded, shoulda-matchers automatically includes itself into your test
127
- framework. It will mix in the appropriate matchers for ActiveRecord,
128
- ActiveModel, and ActionController depending on the modules that are available at
129
- runtime. For instance, in order to use the ActiveRecord matchers, ActiveRecord
130
- must be present beforehand.
134
+ [Then, configure the gem to integrate with Minitest](#configuration).
131
135
 
132
- If your application is written against Rails, everything should "just work", as
133
- shoulda-matchers will most likely be declared after Rails in your Gemfile. If
134
- your application is written against another framework such as Sinatra or
135
- Padrino, you may have a different setup, so you will want to ensure that you are
136
- requiring shoulda-matchers after the components of Rails you are using. For
137
- instance, if you wanted to use and test against ActiveModel, you'd say:
136
+ Now you can use matchers in your tests. For instance a model test might look
137
+ like this:
138
138
 
139
- ```ruby
140
- gem 'activemodel'
141
- gem 'shoulda-matchers'
139
+ ``` ruby
140
+ class PersonTest < ActiveSupport::TestCase
141
+ should validate_presence_of(:name)
142
+ end
142
143
  ```
143
144
 
144
- and not:
145
+ ### Configuration
145
146
 
146
- ```ruby
147
- gem 'shoulda-matchers'
148
- gem 'activemodel'
147
+ **NOTE: The new configuration syntax isn't available in a public release just
148
+ yet -- please refer to the [README for 2.8.0][2.8.0-README] for the current
149
+ installation instructions.**
150
+
151
+ Before you can use Shoulda Matchers, you'll need to tell it a couple of things:
152
+
153
+ * Which test framework you're using
154
+ * Which portion of the matchers you want to use
155
+
156
+ You can supply this information by using a configuration block. Place the
157
+ following in your test or spec helper:
158
+
159
+ ``` ruby
160
+ Shoulda::Matchers.configure do |config|
161
+ config.integrate do |with|
162
+ # Choose a test framework:
163
+ with.test_framework :rspec
164
+ with.test_framework :minitest
165
+ with.test_framework :minitest_4
166
+ with.test_framework :test_unit
167
+
168
+ # Choose one or more libraries:
169
+ with.library :active_record
170
+ with.library :active_model
171
+ with.library :action_controller
172
+ # Or, choose the following (which implies all of the above):
173
+ with.library :rails
174
+ end
175
+ end
149
176
  ```
150
177
 
151
178
  ## Generating documentation
@@ -160,31 +187,49 @@ from this directory. Then, open `doc/index.html` in your browser.
160
187
  If you want to see a live preview as you work without having to run `yard` over
161
188
  and over again, keep this command running in a separate terminal session:
162
189
 
163
- watchr docs.watchr
190
+ bundle exec guard
164
191
 
165
- ## Versioning
192
+ ## Contributing
166
193
 
167
- shoulda-matchers follows Semantic Versioning 2.0 as defined at
168
- <http://semver.org>.
194
+ Shoulda Matchers is open source, and we are grateful for
195
+ [everyone][contributors] who's contributed so far.
169
196
 
170
- ## Credits
197
+ If you'd like to contribute, please take a look at the
198
+ [instructions](CONTRIBUTING.md) for installing dependencies and crafting a good
199
+ pull request.
171
200
 
172
- shoulda-matchers is maintained and funded by [thoughtbot][community]. Thank you
173
- to all the [contributors][contributors].
201
+ ## Versioning
202
+
203
+ Shoulda Matchers follows Semantic Versioning 2.0 as defined at
204
+ <http://semver.org>.
174
205
 
175
206
  ## License
176
207
 
177
- shoulda-matchers is copyright © 2006-2014 thoughtbot, inc. It is free software,
208
+ Shoulda Matchers is copyright © 2006-2015
209
+ [thoughtbot, inc](https://thoughtbot.com/). It is free software,
178
210
  and may be redistributed under the terms specified in the
179
211
  [MIT-LICENSE](MIT-LICENSE) file.
180
212
 
213
+ ## About thoughtbot
214
+
215
+ ![thoughtbot](https://thoughtbot.com/logo.png)
216
+
217
+ Shoulda Matchers is maintained and funded by thoughtbot, inc.
218
+ The names and logos for thoughtbot are trademarks of thoughtbot, inc.
219
+
220
+ We are passionate about open source software.
221
+ See [our other projects][community].
222
+ We are [available for hire][hire].
223
+
224
+ [community]: https://thoughtbot.com/community?utm_source=github
225
+ [hire]: https://thoughtbot.com?utm_source=github
181
226
  [version-badge]: http://img.shields.io/gem/v/shoulda-matchers.svg
182
227
  [rubygems]: http://rubygems.org/gems/shoulda-matchers
183
228
  [travis-badge]: http://img.shields.io/travis/thoughtbot/shoulda-matchers/master.svg
184
229
  [travis]: http://travis-ci.org/thoughtbot/shoulda-matchers
185
230
  [downloads-badge]: http://img.shields.io/gem/dtv/shoulda-matchers.svg
186
231
  [rubydocs]: http://matchers.shoulda.io/docs
187
- [community]: http://thoughtbot.com/community
188
232
  [contributors]: https://github.com/thoughtbot/shoulda-matchers/contributors
189
233
  [shoulda]: http://github.com/thoughtbot/shoulda
190
234
  [shoulda-context]: http://github.com/thoughtbot/shoulda-context
235
+ [2.8.0-README]: https://github.com/thoughtbot/shoulda-matchers/tree/v2.8.0#shoulda-matchers---
data/Rakefile CHANGED
@@ -3,6 +3,7 @@ require 'bundler/gem_tasks'
3
3
  require 'rspec/core/rake_task'
4
4
  require 'appraisal'
5
5
  require_relative 'tasks/documentation'
6
+ require_relative 'spec/support/tests/database'
6
7
 
7
8
  RSpec::Core::RakeTask.new('spec:unit') do |t|
8
9
  t.ruby_opts = '-w -r ./spec/report_warnings'