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
@@ -1,12 +1,13 @@
1
- StringLiterals:
2
- EnforcedStyle: single_quotes
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
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'appraisal', '~> 2.0'
4
4
  gem 'bundler', '~> 1.1'
5
- gem 'pry', github: 'pry/pry'
5
+ gem 'pry', git: 'https://github.com/pry/pry.git'
6
6
  gem 'pry-byebug'
7
7
  gem 'rake', '>= 10.5.0', '< 11'
8
8
  gem 'rspec', '~> 3.2'
@@ -1,11 +1,10 @@
1
1
  GIT
2
- remote: git://github.com/pry/pry.git
3
- revision: f0cbec507111743fdbc273735ea4f0f6164a5b21
2
+ remote: https://github.com/pry/pry.git
3
+ revision: 1f64463184e0a160d0b41d1a1f92b8e2f230278c
4
4
  specs:
5
- pry (0.10.1)
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 (4.0.4)
18
- columnize (= 0.9.0)
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
- posix-spawn (0.3.8)
25
- pry-byebug (3.1.0)
26
- byebug (~> 4.0)
21
+ multi_json (1.12.1)
22
+ pry-byebug (3.4.2)
23
+ byebug (~> 9.0)
27
24
  pry (~> 0.10)
28
- pygments.rb (0.3.7)
29
- posix-spawn (~> 0.3.6)
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.0.0)
33
- rspec (3.4.0)
34
- rspec-core (~> 3.4.0)
35
- rspec-expectations (~> 3.4.0)
36
- rspec-mocks (~> 3.4.0)
37
- rspec-core (3.4.1)
38
- rspec-support (~> 3.4.0)
39
- rspec-expectations (3.4.0)
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.4.0)
42
- rspec-mocks (3.4.0)
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.4.0)
45
- rspec-support (3.4.1)
46
- slop (3.6.0)
47
- thor (0.19.1)
48
- yajl-ruby (1.1.0)
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.11.2
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.0.0).][rubydocs]
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
- gem 'shoulda-matchers', '~> 3.0'
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.0,
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](https://thoughtbot.com/logo.png)
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
@@ -10,7 +10,7 @@ module Shoulda
10
10
  # end
11
11
  #
12
12
  # # RSpec
13
- # describe ApplicationController do
13
+ # RSpec.describe ApplicationController, type: :controller do
14
14
  # it { should filter_param(:secret_key) }
15
15
  # end
16
16
  #
@@ -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
- @parameters_double_registries_by_params = {}
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
- parameters_double_registries_by_params[params] =
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
- parameters_double_registries_by_params.flat_map do |params, double_registry|
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 :parameters_double_registries_by_params
362
+ attr_reader :parameters_double_registries
364
363
  end
365
364
 
366
365
  # @private
@@ -14,7 +14,7 @@ module Shoulda
14
14
  # end
15
15
  #
16
16
  # # RSpec
17
- # describe PostsController do
17
+ # RSpec.describe PostsController, type: :controller do
18
18
  # describe 'GET #show' do
19
19
  # before { get :show }
20
20
  #
@@ -15,7 +15,7 @@ module Shoulda
15
15
  # <%= render 'sidebar' %>
16
16
  #
17
17
  # # RSpec
18
- # describe PostsController do
18
+ # RSpec.describe PostsController, type: :controller do
19
19
  # describe 'GET #show' do
20
20
  # before { get :show }
21
21
  #
@@ -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
  #
@@ -16,7 +16,7 @@ module Shoulda
16
16
  # end
17
17
  #
18
18
  # # RSpec
19
- # describe ApplicationController do
19
+ # RSpec.describe ApplicationController, type: :controller do
20
20
  # it do
21
21
  # should rescue_from(ActiveRecord::RecordNotFound).
22
22
  # with(:handle_not_found)
@@ -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)