shoulda-matchers 3.1.1 → 3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +1 -1
- data/.hound/ruby.yml +1042 -0
- data/{.hound_config/ruby.yml → .rubocop.yml} +7 -6
- data/Gemfile +1 -1
- data/Gemfile.lock +26 -32
- data/NEWS.md +18 -0
- data/README.md +32 -6
- data/docs/errors/NonCaseSwappableValueError.md +2 -2
- data/lib/shoulda/matchers/action_controller/callback_matcher.rb +6 -6
- data/lib/shoulda/matchers/action_controller/filter_param_matcher.rb +1 -1
- data/lib/shoulda/matchers/action_controller/permit_matcher.rb +7 -8
- data/lib/shoulda/matchers/action_controller/redirect_to_matcher.rb +1 -1
- data/lib/shoulda/matchers/action_controller/render_template_matcher.rb +1 -1
- data/lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb +2 -2
- data/lib/shoulda/matchers/action_controller/rescue_from_matcher.rb +1 -1
- data/lib/shoulda/matchers/action_controller/respond_with_matcher.rb +3 -3
- data/lib/shoulda/matchers/action_controller/route_matcher.rb +2 -2
- data/lib/shoulda/matchers/action_controller/set_flash_matcher.rb +4 -4
- data/lib/shoulda/matchers/action_controller/set_session_matcher.rb +3 -3
- data/lib/shoulda/matchers/active_model.rb +1 -1
- data/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb +3 -3
- data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +10 -10
- data/lib/shoulda/matchers/active_model/have_secure_password_matcher.rb +1 -1
- data/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +3 -3
- data/lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb +3 -3
- data/lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb +3 -3
- data/lib/shoulda/matchers/active_model/validate_exclusion_of_matcher.rb +4 -4
- data/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +8 -8
- data/lib/shoulda/matchers/active_model/validate_length_of_matcher.rb +8 -8
- data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +12 -12
- data/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb +4 -4
- data/lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb +4 -4
- data/lib/shoulda/matchers/active_record/association_matcher.rb +61 -43
- data/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb +2 -3
- data/lib/shoulda/matchers/active_record/have_db_column_matcher.rb +3 -3
- data/lib/shoulda/matchers/active_record/have_db_index_matcher.rb +3 -3
- data/lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb +1 -1
- data/lib/shoulda/matchers/active_record/serialize_matcher.rb +3 -3
- data/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +11 -11
- data/lib/shoulda/matchers/version.rb +1 -1
- data/spec/unit/shoulda/matchers/action_controller/permit_matcher_spec.rb +9 -0
- metadata +5 -5
@@ -1,12 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
AlignParameters:
|
1
|
+
inherit_from: .hound/ruby.yml
|
2
|
+
Style/AlignParameters:
|
5
3
|
EnforcedStyle: with_fixed_indentation
|
6
|
-
|
7
|
-
CollectionMethods:
|
4
|
+
Style/CollectionMethods:
|
8
5
|
PreferredMethods:
|
9
6
|
find: detect
|
10
7
|
reduce: inject
|
11
8
|
collect: map
|
12
9
|
find_all: select
|
10
|
+
Style/FrozenStringLiteralComment:
|
11
|
+
Enabled: false
|
12
|
+
Style/StringLiterals:
|
13
|
+
EnforcedStyle: single_quotes
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
GIT
|
2
|
-
remote:
|
3
|
-
revision:
|
2
|
+
remote: https://github.com/pry/pry.git
|
3
|
+
revision: 1f64463184e0a160d0b41d1a1f92b8e2f230278c
|
4
4
|
specs:
|
5
|
-
pry (0.10.
|
5
|
+
pry (0.10.4)
|
6
6
|
coderay (~> 1.1.0)
|
7
7
|
method_source (~> 0.8.1)
|
8
|
-
slop (~> 3.4)
|
9
8
|
|
10
9
|
GEM
|
11
10
|
remote: https://rubygems.org/
|
@@ -14,40 +13,35 @@ GEM
|
|
14
13
|
bundler
|
15
14
|
rake
|
16
15
|
thor (>= 0.14.0)
|
17
|
-
byebug (
|
18
|
-
|
19
|
-
coderay (1.1.0)
|
20
|
-
columnize (0.9.0)
|
16
|
+
byebug (9.0.6)
|
17
|
+
coderay (1.1.1)
|
21
18
|
diff-lcs (1.2.5)
|
22
19
|
fssm (0.2.10)
|
23
20
|
method_source (0.8.2)
|
24
|
-
|
25
|
-
pry-byebug (3.
|
26
|
-
byebug (~>
|
21
|
+
multi_json (1.12.1)
|
22
|
+
pry-byebug (3.4.2)
|
23
|
+
byebug (~> 9.0)
|
27
24
|
pry (~> 0.10)
|
28
|
-
pygments.rb (
|
29
|
-
|
30
|
-
yajl-ruby (~> 1.1.0)
|
25
|
+
pygments.rb (1.1.1)
|
26
|
+
multi_json (>= 1.0.0)
|
31
27
|
rake (10.5.0)
|
32
|
-
redcarpet (3.
|
33
|
-
rspec (3.
|
34
|
-
rspec-core (~> 3.
|
35
|
-
rspec-expectations (~> 3.
|
36
|
-
rspec-mocks (~> 3.
|
37
|
-
rspec-core (3.4
|
38
|
-
rspec-support (~> 3.
|
39
|
-
rspec-expectations (3.
|
28
|
+
redcarpet (3.4.0)
|
29
|
+
rspec (3.5.0)
|
30
|
+
rspec-core (~> 3.5.0)
|
31
|
+
rspec-expectations (~> 3.5.0)
|
32
|
+
rspec-mocks (~> 3.5.0)
|
33
|
+
rspec-core (3.5.4)
|
34
|
+
rspec-support (~> 3.5.0)
|
35
|
+
rspec-expectations (3.5.0)
|
40
36
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
-
rspec-support (~> 3.
|
42
|
-
rspec-mocks (3.
|
37
|
+
rspec-support (~> 3.5.0)
|
38
|
+
rspec-mocks (3.5.0)
|
43
39
|
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
-
rspec-support (~> 3.
|
45
|
-
rspec-support (3.
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
yard (0.8.7.3)
|
50
|
-
zeus (0.15.4)
|
40
|
+
rspec-support (~> 3.5.0)
|
41
|
+
rspec-support (3.5.0)
|
42
|
+
thor (0.19.4)
|
43
|
+
yard (0.9.6)
|
44
|
+
zeus (0.15.12)
|
51
45
|
method_source (>= 0.6.7)
|
52
46
|
|
53
47
|
PLATFORMS
|
@@ -67,4 +61,4 @@ DEPENDENCIES
|
|
67
61
|
zeus
|
68
62
|
|
69
63
|
BUNDLED WITH
|
70
|
-
1.
|
64
|
+
1.13.6
|
data/NEWS.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
# 3.1.2
|
2
|
+
|
3
|
+
### Deprecations
|
4
|
+
|
5
|
+
* This is the **last version** that supports Rails 4.0 and 4.1 and Ruby 2.0 and 2.1.
|
6
|
+
|
7
|
+
### Bug fixes
|
8
|
+
|
9
|
+
* When the `permit` matcher was used without `#on`, the controller did not use
|
10
|
+
`params#require`, the params object was duplicated, and the matcher did not
|
11
|
+
recognize the `#permit` call inside the controller. This behavior happened
|
12
|
+
because the matcher overwrote double registries with the same parameter hash
|
13
|
+
whenever ActionController::Parameters was instantiated.
|
14
|
+
|
15
|
+
* *Commit: [44c019]*
|
16
|
+
* *Issue: [#899]*
|
17
|
+
* *Pull request: [#902]*
|
18
|
+
|
1
19
|
# 3.1.1
|
2
20
|
|
3
21
|
### Bug fixes
|
data/README.md
CHANGED
@@ -1,10 +1,26 @@
|
|
1
1
|
# Shoulda Matchers [![Gem Version][version-badge]][rubygems] [![Build Status][travis-badge]][travis] ![Downloads][downloads-badge]
|
2
2
|
|
3
|
+
[![Join the chat at https://gitter.im/shoulda-matchers/Lobby](https://badges.gitter.im/shoulda-matchers/Lobby.svg)](https://gitter.im/shoulda-matchers/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
|
+
|
3
5
|
Shoulda Matchers provides RSpec- and Minitest-compatible one-liners that test
|
4
6
|
common Rails functionality. These tests would otherwise be much longer, more
|
5
7
|
complex, and error-prone.
|
6
8
|
|
7
|
-
[View the official documentation for the latest version (3.
|
9
|
+
[View the official documentation for the latest version (3.1.1).][rubydocs]
|
10
|
+
|
11
|
+
----
|
12
|
+
|
13
|
+
### Note from the maintainer
|
14
|
+
|
15
|
+
> Are you a fan of Shoulda Matchers? Are you interested in maintaining a popular
|
16
|
+
> open-source project? If so, please contact me. Don't misunderstand me -- I
|
17
|
+
> still use Shoulda Matchers on every project, but unfortunately, it has been a
|
18
|
+
> long while since I've been able to give it the love it deserves, and I'd like
|
19
|
+
> to hand the reins over to someone else who is able to do that. If you're
|
20
|
+
> interested, I can be reached on Twitter as @mcmire or at
|
21
|
+
> <elliot.winkler@gmail.com>. Thanks!
|
22
|
+
>
|
23
|
+
> -- Elliot
|
8
24
|
|
9
25
|
----
|
10
26
|
|
@@ -103,9 +119,19 @@ complex, and error-prone.
|
|
103
119
|
|
104
120
|
Include `shoulda-matchers` in your Gemfile:
|
105
121
|
|
122
|
+
For Rails 4.x:
|
123
|
+
|
124
|
+
``` ruby
|
125
|
+
group :test do
|
126
|
+
gem 'shoulda-matchers', '~> 3.1'
|
127
|
+
end
|
128
|
+
```
|
129
|
+
|
130
|
+
For Rails 5.0:
|
131
|
+
|
106
132
|
``` ruby
|
107
133
|
group :test do
|
108
|
-
|
134
|
+
gem 'shoulda-matchers', git: 'https://github.com/thoughtbot/shoulda-matchers.git', branch: 'rails-5'
|
109
135
|
end
|
110
136
|
```
|
111
137
|
|
@@ -140,7 +166,7 @@ Now you can use matchers in your tests. For instance a model test might look
|
|
140
166
|
like this:
|
141
167
|
|
142
168
|
``` ruby
|
143
|
-
describe Person do
|
169
|
+
RSpec.describe Person, type: :model do
|
144
170
|
it { should validate_presence_of(:name) }
|
145
171
|
end
|
146
172
|
```
|
@@ -188,7 +214,7 @@ use it even when using the `expect` syntax. But if you prefer to use
|
|
188
214
|
`is_expected.to`, you can do that too:
|
189
215
|
|
190
216
|
``` ruby
|
191
|
-
describe Person do
|
217
|
+
RSpec.describe Person, type: :model do
|
192
218
|
it { is_expected.to validate_presence_of(:name) }
|
193
219
|
end
|
194
220
|
```
|
@@ -199,7 +225,7 @@ Shoulda Matchers was originally a component of [Shoulda][shoulda], a gem that
|
|
199
225
|
also provides `should` and `context` syntax via
|
200
226
|
[`shoulda-context`][shoulda-context].
|
201
227
|
|
202
|
-
At the moment, `shoulda` has not been updated to support `shoulda-matchers` 3.
|
228
|
+
At the moment, `shoulda` has not been updated to support `shoulda-matchers` 3.x,
|
203
229
|
so you'll want to add the following to your Gemfile:
|
204
230
|
|
205
231
|
```ruby
|
@@ -307,7 +333,7 @@ and may be redistributed under the terms specified in the
|
|
307
333
|
|
308
334
|
## About thoughtbot
|
309
335
|
|
310
|
-
![thoughtbot](
|
336
|
+
![thoughtbot](http://presskit.thoughtbot.com/images/thoughtbot-logo-for-readmes.svg)
|
311
337
|
|
312
338
|
Shoulda Matchers is maintained and funded by thoughtbot, inc.
|
313
339
|
The names and logos for thoughtbot are trademarks of thoughtbot, inc.
|
@@ -46,7 +46,7 @@ error message explains, you have two options:
|
|
46
46
|
end
|
47
47
|
|
48
48
|
# RSpec
|
49
|
-
describe User do
|
49
|
+
RSpec.describe User, type: :model do
|
50
50
|
context "validations" do
|
51
51
|
subject do
|
52
52
|
# Note that "123" == "123".swapcase. This is a problem!
|
@@ -87,7 +87,7 @@ error message explains, you have two options:
|
|
87
87
|
end
|
88
88
|
|
89
89
|
# RSpec
|
90
|
-
describe User do
|
90
|
+
RSpec.describe User, type: :model do
|
91
91
|
context "validations" do
|
92
92
|
subject do
|
93
93
|
# Note that "123" == "123".swapcase, but it's okay
|
@@ -9,7 +9,7 @@ module Shoulda
|
|
9
9
|
# end
|
10
10
|
#
|
11
11
|
# # RSpec
|
12
|
-
# describe UsersController do
|
12
|
+
# RSpec.describe UsersController, type: :controller do
|
13
13
|
# it { should use_before_filter(:authenticate_user!) }
|
14
14
|
# it { should_not use_before_filter(:prevent_ssl) }
|
15
15
|
# end
|
@@ -34,7 +34,7 @@ module Shoulda
|
|
34
34
|
# end
|
35
35
|
#
|
36
36
|
# # RSpec
|
37
|
-
# describe IssuesController do
|
37
|
+
# RSpec.describe IssuesController, type: :controller do
|
38
38
|
# it { should use_after_filter(:log_activity) }
|
39
39
|
# it { should_not use_after_filter(:destroy_user) }
|
40
40
|
# end
|
@@ -59,7 +59,7 @@ module Shoulda
|
|
59
59
|
# end
|
60
60
|
#
|
61
61
|
# # RSpec
|
62
|
-
# describe UsersController do
|
62
|
+
# RSpec.describe UsersController, type: :controller do
|
63
63
|
# it { should use_before_action(:authenticate_user!) }
|
64
64
|
# it { should_not use_before_action(:prevent_ssl) }
|
65
65
|
# end
|
@@ -84,7 +84,7 @@ module Shoulda
|
|
84
84
|
# end
|
85
85
|
#
|
86
86
|
# # RSpec
|
87
|
-
# describe IssuesController do
|
87
|
+
# RSpec.describe IssuesController, type: :controller do
|
88
88
|
# it { should use_after_action(:log_activity) }
|
89
89
|
# it { should_not use_after_action(:destroy_user) }
|
90
90
|
# end
|
@@ -109,7 +109,7 @@ module Shoulda
|
|
109
109
|
# end
|
110
110
|
#
|
111
111
|
# # RSpec
|
112
|
-
# describe ChangesController do
|
112
|
+
# RSpec.describe ChangesController, type: :controller do
|
113
113
|
# it { should use_around_filter(:wrap_in_transaction) }
|
114
114
|
# it { should_not use_around_filter(:save_view_context) }
|
115
115
|
# end
|
@@ -134,7 +134,7 @@ module Shoulda
|
|
134
134
|
# end
|
135
135
|
#
|
136
136
|
# # RSpec
|
137
|
-
# describe ChangesController do
|
137
|
+
# RSpec.describe ChangesController, type: :controller do
|
138
138
|
# it { should use_around_action(:wrap_in_transaction) }
|
139
139
|
# it { should_not use_around_action(:save_view_context) }
|
140
140
|
# end
|
@@ -35,7 +35,7 @@ module Shoulda
|
|
35
35
|
# end
|
36
36
|
#
|
37
37
|
# # RSpec
|
38
|
-
# describe UsersController do
|
38
|
+
# RSpec.describe UsersController, type: :controller do
|
39
39
|
# it do
|
40
40
|
# params = {
|
41
41
|
# user: {
|
@@ -96,7 +96,7 @@ module Shoulda
|
|
96
96
|
# end
|
97
97
|
#
|
98
98
|
# # RSpec
|
99
|
-
# describe UsersController do
|
99
|
+
# RSpec.describe UsersController, type: :controller do
|
100
100
|
# before do
|
101
101
|
# create(:user, id: 1)
|
102
102
|
# end
|
@@ -170,7 +170,7 @@ module Shoulda
|
|
170
170
|
# end
|
171
171
|
#
|
172
172
|
# # RSpec
|
173
|
-
# describe UsersController do
|
173
|
+
# RSpec.describe UsersController, type: :controller do
|
174
174
|
# before do
|
175
175
|
# create(:user, id: 1)
|
176
176
|
# end
|
@@ -336,7 +336,7 @@ module Shoulda
|
|
336
336
|
# @private
|
337
337
|
class CompositeParametersDoubleRegistry
|
338
338
|
def initialize
|
339
|
-
@
|
339
|
+
@parameters_double_registries = []
|
340
340
|
end
|
341
341
|
|
342
342
|
def register
|
@@ -347,20 +347,19 @@ module Shoulda
|
|
347
347
|
params = call.return_value
|
348
348
|
parameters_double_registry = ParametersDoubleRegistry.new(params)
|
349
349
|
parameters_double_registry.register
|
350
|
-
|
351
|
-
parameters_double_registry
|
350
|
+
parameters_double_registries << parameters_double_registry
|
352
351
|
end
|
353
352
|
end
|
354
353
|
|
355
354
|
def permitted_parameter_names(options = {})
|
356
|
-
|
355
|
+
parameters_double_registries.flat_map do |double_registry|
|
357
356
|
double_registry.permitted_parameter_names(options)
|
358
357
|
end
|
359
358
|
end
|
360
359
|
|
361
360
|
protected
|
362
361
|
|
363
|
-
attr_reader :
|
362
|
+
attr_reader :parameters_double_registries
|
364
363
|
end
|
365
364
|
|
366
365
|
# @private
|
@@ -11,7 +11,7 @@ module Shoulda
|
|
11
11
|
# end
|
12
12
|
#
|
13
13
|
# # RSpec
|
14
|
-
# describe PostsController do
|
14
|
+
# RSpec.describe PostsController, type: :controller do
|
15
15
|
# describe 'GET #show' do
|
16
16
|
# before { get :show }
|
17
17
|
#
|
@@ -38,7 +38,7 @@ module Shoulda
|
|
38
38
|
# end
|
39
39
|
#
|
40
40
|
# # RSpec
|
41
|
-
# describe PostsController do
|
41
|
+
# RSpec.describe PostsController, type: :controller do
|
42
42
|
# describe 'GET #sidebar' do
|
43
43
|
# before { get :sidebar }
|
44
44
|
#
|
@@ -13,7 +13,7 @@ module Shoulda
|
|
13
13
|
# end
|
14
14
|
#
|
15
15
|
# # RSpec
|
16
|
-
# describe PostsController do
|
16
|
+
# RSpec.describe PostsController, type: :controller do
|
17
17
|
# describe 'GET #index' do
|
18
18
|
# before { get :index }
|
19
19
|
#
|
@@ -39,7 +39,7 @@ module Shoulda
|
|
39
39
|
# end
|
40
40
|
#
|
41
41
|
# # RSpec
|
42
|
-
# describe PostsController do
|
42
|
+
# RSpec.describe PostsController, type: :controller do
|
43
43
|
# describe 'DELETE #destroy' do
|
44
44
|
# before { delete :destroy }
|
45
45
|
#
|
@@ -65,7 +65,7 @@ module Shoulda
|
|
65
65
|
# end
|
66
66
|
#
|
67
67
|
# # RSpec
|
68
|
-
# describe PostsController do
|
68
|
+
# RSpec.describe PostsController, type: :controller do
|
69
69
|
# describe 'GET #show' do
|
70
70
|
# before { get :show }
|
71
71
|
#
|
@@ -24,7 +24,7 @@ module Shoulda
|
|
24
24
|
# end
|
25
25
|
#
|
26
26
|
# # RSpec
|
27
|
-
# describe PostsController do
|
27
|
+
# RSpec.describe PostsController, type: :controller do
|
28
28
|
# it { should route(:get, '/posts').to(action: :index) }
|
29
29
|
# it { should route(:get, '/posts/1').to(action: :show, id: 1) }
|
30
30
|
# end
|
@@ -38,7 +38,7 @@ module Shoulda
|
|
38
38
|
# Or you could place the tests along with other route tests:
|
39
39
|
#
|
40
40
|
# # RSpec
|
41
|
-
# describe 'Routing' do
|
41
|
+
# describe 'Routing', type: :routing do
|
42
42
|
# it do
|
43
43
|
# should route(:get, '/posts').
|
44
44
|
# to(controller: :posts, action: :index)
|