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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +1 -1
  3. data/.hound/ruby.yml +1042 -0
  4. data/{.hound_config/ruby.yml → .rubocop.yml} +7 -6
  5. data/Gemfile +1 -1
  6. data/Gemfile.lock +26 -32
  7. data/NEWS.md +18 -0
  8. data/README.md +32 -6
  9. data/docs/errors/NonCaseSwappableValueError.md +2 -2
  10. data/lib/shoulda/matchers/action_controller/callback_matcher.rb +6 -6
  11. data/lib/shoulda/matchers/action_controller/filter_param_matcher.rb +1 -1
  12. data/lib/shoulda/matchers/action_controller/permit_matcher.rb +7 -8
  13. data/lib/shoulda/matchers/action_controller/redirect_to_matcher.rb +1 -1
  14. data/lib/shoulda/matchers/action_controller/render_template_matcher.rb +1 -1
  15. data/lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb +2 -2
  16. data/lib/shoulda/matchers/action_controller/rescue_from_matcher.rb +1 -1
  17. data/lib/shoulda/matchers/action_controller/respond_with_matcher.rb +3 -3
  18. data/lib/shoulda/matchers/action_controller/route_matcher.rb +2 -2
  19. data/lib/shoulda/matchers/action_controller/set_flash_matcher.rb +4 -4
  20. data/lib/shoulda/matchers/action_controller/set_session_matcher.rb +3 -3
  21. data/lib/shoulda/matchers/active_model.rb +1 -1
  22. data/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb +3 -3
  23. data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +10 -10
  24. data/lib/shoulda/matchers/active_model/have_secure_password_matcher.rb +1 -1
  25. data/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +3 -3
  26. data/lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb +3 -3
  27. data/lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb +3 -3
  28. data/lib/shoulda/matchers/active_model/validate_exclusion_of_matcher.rb +4 -4
  29. data/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +8 -8
  30. data/lib/shoulda/matchers/active_model/validate_length_of_matcher.rb +8 -8
  31. data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +12 -12
  32. data/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb +4 -4
  33. data/lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb +4 -4
  34. data/lib/shoulda/matchers/active_record/association_matcher.rb +61 -43
  35. data/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb +2 -3
  36. data/lib/shoulda/matchers/active_record/have_db_column_matcher.rb +3 -3
  37. data/lib/shoulda/matchers/active_record/have_db_index_matcher.rb +3 -3
  38. data/lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb +1 -1
  39. data/lib/shoulda/matchers/active_record/serialize_matcher.rb +3 -3
  40. data/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +11 -11
  41. data/lib/shoulda/matchers/version.rb +1 -1
  42. data/spec/unit/shoulda/matchers/action_controller/permit_matcher_spec.rb +9 -0
  43. metadata +5 -5
@@ -16,7 +16,7 @@ module Shoulda
16
16
  # end
17
17
  #
18
18
  # # RSpec
19
- # describe PostsController do
19
+ # RSpec.describe PostsController, type: :controller do
20
20
  # describe 'GET #index' do
21
21
  # before { get :index }
22
22
  #
@@ -58,7 +58,7 @@ module Shoulda
58
58
  # end
59
59
  #
60
60
  # # RSpec
61
- # describe PostsController do
61
+ # RSpec.describe PostsController, type: :controller do
62
62
  # describe 'GET #index' do
63
63
  # before { get :index }
64
64
  #
@@ -89,7 +89,7 @@ module Shoulda
89
89
  # end
90
90
  #
91
91
  # # RSpec
92
- # describe PostsController do
92
+ # RSpec.describe PostsController, type: :controller do
93
93
  # describe 'GET #index' do
94
94
  # before { get :index }
95
95
  #
@@ -124,7 +124,7 @@ module Shoulda
124
124
  # end
125
125
  #
126
126
  # # RSpec
127
- # describe PostsController do
127
+ # RSpec.describe PostsController, type: :controller do
128
128
  # describe 'GET #show' do
129
129
  # before { get :show }
130
130
  #
@@ -16,7 +16,7 @@ module Shoulda
16
16
  # end
17
17
  #
18
18
  # # RSpec
19
- # describe PostsController do
19
+ # RSpec.describe PostsController, type: :controller do
20
20
  # describe 'GET #index' do
21
21
  # before { get :index }
22
22
  #
@@ -58,7 +58,7 @@ module Shoulda
58
58
  # end
59
59
  #
60
60
  # # RSpec
61
- # describe PostsController do
61
+ # RSpec.describe PostsController, type: :controller do
62
62
  # describe 'GET #index' do
63
63
  # before { get :index }
64
64
  #
@@ -89,7 +89,7 @@ module Shoulda
89
89
  # end
90
90
  #
91
91
  # # RSpec
92
- # describe PostsController do
92
+ # RSpec.describe PostsController, type: :controller do
93
93
  # describe 'GET #index' do
94
94
  # before { get :index }
95
95
  #
@@ -60,7 +60,7 @@ module Shoulda
60
60
  # end
61
61
  #
62
62
  # # RSpec
63
- # describe User do
63
+ # RSpec.describe User, type: :model do
64
64
  # context "when an admin" do
65
65
  # subject { User.new(admin: true) }
66
66
  #
@@ -23,11 +23,11 @@ module Shoulda
23
23
  # end
24
24
  #
25
25
  # # RSpec
26
- # describe Post do
26
+ # RSpec.describe Post, type: :model do
27
27
  # it { should allow_mass_assignment_of(:title) }
28
28
  # end
29
29
  #
30
- # describe User do
30
+ # RSpec.describe User, type: :model do
31
31
  # it { should_not allow_mass_assignment_of(:encrypted_password) }
32
32
  # end
33
33
  #
@@ -56,7 +56,7 @@ module Shoulda
56
56
  # end
57
57
  #
58
58
  # # RSpec
59
- # describe Post do
59
+ # RSpec.describe Post, type: :model do
60
60
  # it { should allow_mass_assignment_of(:title).as(:admin) }
61
61
  # end
62
62
  #
@@ -17,7 +17,7 @@ module Shoulda
17
17
  # You can use `allow_value` to test one value at a time:
18
18
  #
19
19
  # # RSpec
20
- # describe UserProfile do
20
+ # RSpec.describe UserProfile, type: :model do
21
21
  # it { should allow_value('http://foo.com').for(:website_url) }
22
22
  # it { should allow_value('http://bar.com').for(:website_url) }
23
23
  # end
@@ -34,7 +34,7 @@ module Shoulda
34
34
  # that none of the values cause the record to be valid:
35
35
  #
36
36
  # # RSpec
37
- # describe UserProfile do
37
+ # RSpec.describe UserProfile, type: :model do
38
38
  # it do
39
39
  # should allow_values('http://foo.com', 'http://bar.com').
40
40
  # for(:website_url)
@@ -82,7 +82,7 @@ module Shoulda
82
82
  # end
83
83
  # end
84
84
  #
85
- # describe Foo do
85
+ # RSpec.describe Foo, type: :model do
86
86
  # it do
87
87
  # foo = Foo.new
88
88
  # foo.bar = "baz"
@@ -105,7 +105,7 @@ module Shoulda
105
105
  # end
106
106
  # end
107
107
  #
108
- # describe Foo do
108
+ # RSpec.describe Foo, type: :model do
109
109
  # it do
110
110
  # foo = Foo.new
111
111
  # # This will raise an AttributeChangedValueError since `foo.bar` is now "123"
@@ -116,7 +116,7 @@ module Shoulda
116
116
  # * You're passing a value to `allow_value` that the model typecasts into
117
117
  # another value:
118
118
  #
119
- # describe Foo do
119
+ # RSpec.describe Foo, type: :model do
120
120
  # # Assume that `attr` is a string
121
121
  # # This will raise an AttributeChangedValueError since `attr` typecasts `[]` to `"[]"`
122
122
  # it { should_not allow_value([]).for(:attr) }
@@ -154,7 +154,7 @@ module Shoulda
154
154
  # end
155
155
  #
156
156
  # # RSpec
157
- # describe UserProfile do
157
+ # RSpec.describe UserProfile, type: :model do
158
158
  # it do
159
159
  # should allow_value('2013-01-01').
160
160
  # for(:birthday_as_string).
@@ -183,7 +183,7 @@ module Shoulda
183
183
  # end
184
184
  #
185
185
  # # RSpec
186
- # describe UserProfile do
186
+ # RSpec.describe UserProfile, type: :model do
187
187
  # it do
188
188
  # should allow_value('open', 'closed').
189
189
  # for(:state).
@@ -210,7 +210,7 @@ module Shoulda
210
210
  # end
211
211
  #
212
212
  # # RSpec
213
- # describe UserProfile do
213
+ # RSpec.describe UserProfile, type: :model do
214
214
  # it do
215
215
  # should allow_value('open', 'closed').
216
216
  # for(:state).
@@ -246,7 +246,7 @@ module Shoulda
246
246
  # end
247
247
  #
248
248
  # # RSpec
249
- # describe UserProfile do
249
+ # RSpec.describe UserProfile, type: :model do
250
250
  # it do
251
251
  # should allow_value('Broncos', 'Titans').
252
252
  # for(:sports_team).
@@ -276,7 +276,7 @@ module Shoulda
276
276
  # end
277
277
  #
278
278
  # # RSpec
279
- # describe Address do
279
+ # RSpec.describe Address, type: :model do
280
280
  # it do
281
281
  # should_not allow_value([]).
282
282
  # for(:zip_code).
@@ -15,7 +15,7 @@ module Shoulda
15
15
  # end
16
16
  #
17
17
  # # RSpec
18
- # describe User do
18
+ # RSpec.describe User, type: :model do
19
19
  # it { should have_secure_password }
20
20
  # end
21
21
  #
@@ -12,7 +12,7 @@ module Shoulda
12
12
  # end
13
13
  #
14
14
  # # RSpec
15
- # describe PowerHungryCountry do
15
+ # RSpec.describe PowerHungryCountry, type: :model do
16
16
  # it { should validate_absence_of(:nuclear_weapons) }
17
17
  # end
18
18
  #
@@ -35,7 +35,7 @@ module Shoulda
35
35
  # end
36
36
  #
37
37
  # # RSpec
38
- # describe PowerHungryCountry do
38
+ # RSpec.describe PowerHungryCountry, type: :model do
39
39
  # it { should validate_absence_of(:nuclear_weapons).on(:create) }
40
40
  # end
41
41
  #
@@ -57,7 +57,7 @@ module Shoulda
57
57
  # end
58
58
  #
59
59
  # # RSpec
60
- # describe PowerHungryCountry do
60
+ # RSpec.describe PowerHungryCountry, type: :model do
61
61
  # it do
62
62
  # should validate_absence_of(:nuclear_weapons).
63
63
  # with_message("there shall be peace on Earth")
@@ -12,7 +12,7 @@ module Shoulda
12
12
  # end
13
13
  #
14
14
  # # RSpec
15
- # describe Registration do
15
+ # RSpec.describe Registration, type: :model do
16
16
  # it { should validate_acceptance_of(:eula) }
17
17
  # end
18
18
  #
@@ -35,7 +35,7 @@ module Shoulda
35
35
  # end
36
36
  #
37
37
  # # RSpec
38
- # describe Registration do
38
+ # RSpec.describe Registration, type: :model do
39
39
  # it do
40
40
  # should validate_acceptance_of(:terms_of_service).
41
41
  # on(:create)
@@ -60,7 +60,7 @@ module Shoulda
60
60
  # end
61
61
  #
62
62
  # # RSpec
63
- # describe Registration do
63
+ # RSpec.describe Registration, type: :model do
64
64
  # it do
65
65
  # should validate_acceptance_of(:terms_of_service).
66
66
  # with_message('You must accept the terms of service')
@@ -12,7 +12,7 @@ module Shoulda
12
12
  # end
13
13
  #
14
14
  # # RSpec
15
- # describe User do
15
+ # RSpec.describe User, type: :model do
16
16
  # it { should validate_confirmation_of(:email) }
17
17
  # end
18
18
  #
@@ -35,7 +35,7 @@ module Shoulda
35
35
  # end
36
36
  #
37
37
  # # RSpec
38
- # describe User do
38
+ # RSpec.describe User, type: :model do
39
39
  # it { should validate_confirmation_of(:password).on(:create) }
40
40
  # end
41
41
  #
@@ -57,7 +57,7 @@ module Shoulda
57
57
  # end
58
58
  #
59
59
  # # RSpec
60
- # describe User do
60
+ # RSpec.describe User, type: :model do
61
61
  # it do
62
62
  # should validate_confirmation_of(:password).
63
63
  # with_message('Please re-enter your password')
@@ -16,7 +16,7 @@ module Shoulda
16
16
  # end
17
17
  #
18
18
  # # RSpec
19
- # describe Game do
19
+ # RSpec.describe Game, type: :model do
20
20
  # it do
21
21
  # should validate_exclusion_of(:supported_os).
22
22
  # in_array(['Mac', 'Linux'])
@@ -39,7 +39,7 @@ module Shoulda
39
39
  # end
40
40
  #
41
41
  # # RSpec
42
- # describe Game do
42
+ # RSpec.describe Game, type: :model do
43
43
  # it do
44
44
  # should validate_exclusion_of(:floors_with_enemies).
45
45
  # in_range(5..8)
@@ -68,7 +68,7 @@ module Shoulda
68
68
  # end
69
69
  #
70
70
  # # RSpec
71
- # describe Game do
71
+ # RSpec.describe Game, type: :model do
72
72
  # it do
73
73
  # should validate_exclusion_of(:weapon).
74
74
  # in_array(['pistol', 'paintball gun', 'stick']).
@@ -97,7 +97,7 @@ module Shoulda
97
97
  # end
98
98
  #
99
99
  # # RSpec
100
- # describe Game do
100
+ # RSpec.describe Game, type: :model do
101
101
  # it do
102
102
  # should validate_exclusion_of(:weapon).
103
103
  # in_array(['pistol', 'paintball gun', 'stick']).
@@ -19,7 +19,7 @@ module Shoulda
19
19
  # end
20
20
  #
21
21
  # # RSpec
22
- # describe Issue do
22
+ # RSpec.describe Issue, type: :model do
23
23
  # it do
24
24
  # should validate_inclusion_of(:state).
25
25
  # in_array(['open', 'resolved', 'unresolved'])
@@ -42,7 +42,7 @@ module Shoulda
42
42
  # end
43
43
  #
44
44
  # # RSpec
45
- # describe Issue do
45
+ # RSpec.describe Issue, type: :model do
46
46
  # it { should validate_inclusion_of(:state).in_range(1..5) }
47
47
  # end
48
48
  #
@@ -84,7 +84,7 @@ module Shoulda
84
84
  # end
85
85
  #
86
86
  # # RSpec
87
- # describe Issue do
87
+ # RSpec.describe Issue, type: :model do
88
88
  # it do
89
89
  # should validate_inclusion_of(:severity).
90
90
  # in_array(%w(low medium high)).
@@ -113,7 +113,7 @@ module Shoulda
113
113
  # end
114
114
  #
115
115
  # # RSpec
116
- # describe Issue do
116
+ # RSpec.describe Issue, type: :model do
117
117
  # it do
118
118
  # should validate_inclusion_of(:severity).
119
119
  # in_array(%w(low medium high)).
@@ -149,7 +149,7 @@ module Shoulda
149
149
  # end
150
150
  #
151
151
  # # RSpec
152
- # describe Person do
152
+ # RSpec.describe Person, type: :model do
153
153
  # it do
154
154
  # should validate_inclusion_of(:age).
155
155
  # in_range(0..65).
@@ -185,7 +185,7 @@ module Shoulda
185
185
  # end
186
186
  #
187
187
  # # RSpec
188
- # describe Person do
188
+ # RSpec.describe Person, type: :model do
189
189
  # it do
190
190
  # should validate_inclusion_of(:age).
191
191
  # in_range(0..21).
@@ -215,7 +215,7 @@ module Shoulda
215
215
  # end
216
216
  #
217
217
  # # RSpec
218
- # describe Issue do
218
+ # RSpec.describe Issue, type: :model do
219
219
  # it do
220
220
  # should validate_inclusion_of(:state).
221
221
  # in_array(['open', 'resolved', 'unresolved']).
@@ -245,7 +245,7 @@ module Shoulda
245
245
  # end
246
246
  #
247
247
  # # RSpec
248
- # describe Issue do
248
+ # RSpec.describe Issue, type: :model do
249
249
  # it do
250
250
  # should validate_inclusion_of(:state).
251
251
  # in_array(['open', 'resolved', 'unresolved']).
@@ -17,7 +17,7 @@ module Shoulda
17
17
  # end
18
18
  #
19
19
  # # RSpec
20
- # describe User do
20
+ # RSpec.describe User, type: :model do
21
21
  # it do
22
22
  # should validate_length_of(:password).
23
23
  # is_at_least(10).
@@ -47,7 +47,7 @@ module Shoulda
47
47
  #
48
48
  # # RSpec
49
49
  #
50
- # describe User do
50
+ # RSpec.describe User, type: :model do
51
51
  # it { should validate_length_of(:bio).is_at_least(15) }
52
52
  # end
53
53
  #
@@ -71,7 +71,7 @@ module Shoulda
71
71
  # end
72
72
  #
73
73
  # # RSpec
74
- # describe User do
74
+ # RSpec.describe User, type: :model do
75
75
  # it { should validate_length_of(:status_update).is_at_most(140) }
76
76
  # end
77
77
  #
@@ -94,7 +94,7 @@ module Shoulda
94
94
  # end
95
95
  #
96
96
  # # RSpec
97
- # describe User do
97
+ # RSpec.describe User, type: :model do
98
98
  # it { should validate_length_of(:favorite_superhero).is_equal_to(6) }
99
99
  # end
100
100
  #
@@ -116,7 +116,7 @@ module Shoulda
116
116
  # end
117
117
  #
118
118
  # # RSpec
119
- # describe User do
119
+ # RSpec.describe User, type: :model do
120
120
  # it do
121
121
  # should validate_length_of(:password).
122
122
  # is_at_least(5).is_at_most(30)
@@ -143,7 +143,7 @@ module Shoulda
143
143
  # end
144
144
  #
145
145
  # # RSpec
146
- # describe User do
146
+ # RSpec.describe User, type: :model do
147
147
  # it do
148
148
  # should validate_length_of(:password).
149
149
  # is_at_least(10).
@@ -172,7 +172,7 @@ module Shoulda
172
172
  # end
173
173
  #
174
174
  # # RSpec
175
- # describe User do
175
+ # RSpec.describe User, type: :model do
176
176
  # it do
177
177
  # should validate_length_of(:secret_key).
178
178
  # is_at_least(15).
@@ -201,7 +201,7 @@ module Shoulda
201
201
  # end
202
202
  #
203
203
  # # RSpec
204
- # describe User do
204
+ # RSpec.describe User, type: :model do
205
205
  # it do
206
206
  # should validate_length_of(:secret_key).
207
207
  # is_at_most(100).
@@ -12,7 +12,7 @@ module Shoulda
12
12
  # end
13
13
  #
14
14
  # # RSpec
15
- # describe Person do
15
+ # RSpec.describe Person, type: :model do
16
16
  # it { should validate_numericality_of(:gpa) }
17
17
  # end
18
18
  #
@@ -35,7 +35,7 @@ module Shoulda
35
35
  # end
36
36
  #
37
37
  # # RSpec
38
- # describe Person do
38
+ # RSpec.describe Person, type: :model do
39
39
  # it do
40
40
  # should validate_numericality_of(:number_of_dependents).
41
41
  # on(:create)
@@ -61,7 +61,7 @@ module Shoulda
61
61
  # end
62
62
  #
63
63
  # # RSpec
64
- # describe Person do
64
+ # RSpec.describe Person, type: :model do
65
65
  # it { should validate_numericality_of(:age).only_integer }
66
66
  # end
67
67
  #
@@ -85,7 +85,7 @@ module Shoulda
85
85
  # end
86
86
  #
87
87
  # # RSpec
88
- # describe Person do
88
+ # RSpec.describe Person, type: :model do
89
89
  # it do
90
90
  # should validate_numericality_of(:number_of_cars).
91
91
  # is_less_than(2)
@@ -113,7 +113,7 @@ module Shoulda
113
113
  # end
114
114
  #
115
115
  # # RSpec
116
- # describe Person do
116
+ # RSpec.describe Person, type: :model do
117
117
  # it do
118
118
  # should validate_numericality_of(:birth_year).
119
119
  # is_less_than_or_equal_to(1987)
@@ -140,7 +140,7 @@ module Shoulda
140
140
  # end
141
141
  #
142
142
  # # RSpec
143
- # describe Person do
143
+ # RSpec.describe Person, type: :model do
144
144
  # it { should validate_numericality_of(:weight).is_equal_to(150) }
145
145
  # end
146
146
  #
@@ -164,7 +164,7 @@ module Shoulda
164
164
  # end
165
165
  #
166
166
  # # RSpec
167
- # describe Person do
167
+ # RSpec.describe Person, type: :model do
168
168
  # it do
169
169
  # should validate_numericality_of(:height).
170
170
  # is_greater_than_or_equal_to(55)
@@ -191,7 +191,7 @@ module Shoulda
191
191
  # end
192
192
  #
193
193
  # # RSpec
194
- # describe Person do
194
+ # RSpec.describe Person, type: :model do
195
195
  # it do
196
196
  # should validate_numericality_of(:legal_age).
197
197
  # is_greater_than(21)
@@ -217,7 +217,7 @@ module Shoulda
217
217
  # end
218
218
  #
219
219
  # # RSpec
220
- # describe Person do
220
+ # RSpec.describe Person, type: :model do
221
221
  # it { should validate_numericality_of(:birth_month).even }
222
222
  # end
223
223
  #
@@ -240,7 +240,7 @@ module Shoulda
240
240
  # end
241
241
  #
242
242
  # # RSpec
243
- # describe Person do
243
+ # RSpec.describe Person, type: :model do
244
244
  # it { should validate_numericality_of(:birth_day).odd }
245
245
  # end
246
246
  #
@@ -262,7 +262,7 @@ module Shoulda
262
262
  # end
263
263
  #
264
264
  # # RSpec
265
- # describe Person do
265
+ # RSpec.describe Person, type: :model do
266
266
  # it do
267
267
  # should validate_numericality_of(:number_of_dependents).
268
268
  # with_message('Number of dependents must be a number')
@@ -287,7 +287,7 @@ module Shoulda
287
287
  # end
288
288
  #
289
289
  # # RSpec
290
- # describe Post do
290
+ # RSpec.describe Post, type: :model do
291
291
  # it { should validate_numericality_of(:age).allow_nil }
292
292
  # end
293
293
  #