shoulda-matchers 4.4.1 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +22 -0
  3. data/README.md +7 -9
  4. data/lib/shoulda/matchers/action_controller/callback_matcher.rb +4 -2
  5. data/lib/shoulda/matchers/action_controller/filter_param_matcher.rb +3 -2
  6. data/lib/shoulda/matchers/action_controller/permit_matcher.rb +26 -21
  7. data/lib/shoulda/matchers/action_controller/redirect_to_matcher.rb +6 -8
  8. data/lib/shoulda/matchers/action_controller/render_template_matcher.rb +6 -8
  9. data/lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb +16 -13
  10. data/lib/shoulda/matchers/action_controller/rescue_from_matcher.rb +2 -1
  11. data/lib/shoulda/matchers/action_controller/route_matcher.rb +5 -6
  12. data/lib/shoulda/matchers/action_controller/route_params.rb +1 -1
  13. data/lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb +19 -13
  14. data/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb +18 -16
  15. data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +29 -27
  16. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_changed_value_error.rb +1 -1
  17. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setter.rb +5 -5
  18. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setter_and_validator.rb +2 -2
  19. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb +1 -1
  20. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators.rb +1 -1
  21. data/lib/shoulda/matchers/active_model/disallow_value_matcher.rb +1 -1
  22. data/lib/shoulda/matchers/active_model/have_secure_password_matcher.rb +51 -25
  23. data/lib/shoulda/matchers/active_model/helpers.rb +1 -1
  24. data/lib/shoulda/matchers/active_model/numericality_matchers/comparison_matcher.rb +32 -34
  25. data/lib/shoulda/matchers/active_model/numericality_matchers/numeric_type_matcher.rb +1 -1
  26. data/lib/shoulda/matchers/active_model/qualifiers/ignoring_interference_by_writer.rb +1 -1
  27. data/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +9 -1
  28. data/lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb +2 -2
  29. data/lib/shoulda/matchers/active_model/validate_exclusion_of_matcher.rb +8 -7
  30. data/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +26 -25
  31. data/lib/shoulda/matchers/active_model/validate_length_of_matcher.rb +6 -6
  32. data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +39 -26
  33. data/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb +2 -2
  34. data/lib/shoulda/matchers/active_model/validation_matcher.rb +6 -6
  35. data/lib/shoulda/matchers/active_model/validation_matcher/build_description.rb +2 -4
  36. data/lib/shoulda/matchers/active_model/validation_message_finder.rb +2 -4
  37. data/lib/shoulda/matchers/active_model/validator.rb +3 -3
  38. data/lib/shoulda/matchers/active_record.rb +26 -26
  39. data/lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb +6 -3
  40. data/lib/shoulda/matchers/active_record/association_matcher.rb +80 -40
  41. data/lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb +5 -2
  42. data/lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb +4 -4
  43. data/lib/shoulda/matchers/active_record/association_matchers/inverse_of_matcher.rb +1 -1
  44. data/lib/shoulda/matchers/active_record/association_matchers/join_table_matcher.rb +11 -6
  45. data/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +2 -9
  46. data/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +12 -7
  47. data/lib/shoulda/matchers/active_record/association_matchers/option_verifier.rb +23 -5
  48. data/lib/shoulda/matchers/active_record/association_matchers/optional_matcher.rb +3 -3
  49. data/lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb +1 -1
  50. data/lib/shoulda/matchers/active_record/association_matchers/required_matcher.rb +3 -3
  51. data/lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb +3 -2
  52. data/lib/shoulda/matchers/active_record/association_matchers/through_matcher.rb +7 -5
  53. data/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb +8 -8
  54. data/lib/shoulda/matchers/active_record/have_attached_matcher.rb +46 -8
  55. data/lib/shoulda/matchers/active_record/have_db_column_matcher.rb +39 -17
  56. data/lib/shoulda/matchers/active_record/have_db_index_matcher.rb +1 -1
  57. data/lib/shoulda/matchers/active_record/have_implicit_order_column.rb +7 -7
  58. data/lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb +12 -10
  59. data/lib/shoulda/matchers/active_record/have_rich_text_matcher.rb +11 -7
  60. data/lib/shoulda/matchers/active_record/have_secure_token_matcher.rb +2 -0
  61. data/lib/shoulda/matchers/active_record/serialize_matcher.rb +13 -9
  62. data/lib/shoulda/matchers/active_record/uniqueness.rb +1 -1
  63. data/lib/shoulda/matchers/active_record/uniqueness/test_model_creator.rb +1 -3
  64. data/lib/shoulda/matchers/active_record/uniqueness/test_models.rb +0 -2
  65. data/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +78 -71
  66. data/lib/shoulda/matchers/doublespeak.rb +2 -1
  67. data/lib/shoulda/matchers/doublespeak/double.rb +1 -1
  68. data/lib/shoulda/matchers/doublespeak/double_collection.rb +3 -3
  69. data/lib/shoulda/matchers/doublespeak/double_implementation_registry.rb +8 -5
  70. data/lib/shoulda/matchers/doublespeak/object_double.rb +1 -1
  71. data/lib/shoulda/matchers/doublespeak/stub_implementation.rb +1 -5
  72. data/lib/shoulda/matchers/doublespeak/world.rb +2 -2
  73. data/lib/shoulda/matchers/error.rb +1 -1
  74. data/lib/shoulda/matchers/independent/delegate_method_matcher.rb +14 -13
  75. data/lib/shoulda/matchers/integrations/configuration.rb +1 -1
  76. data/lib/shoulda/matchers/integrations/libraries/action_controller.rb +1 -1
  77. data/lib/shoulda/matchers/integrations/libraries/rails.rb +2 -2
  78. data/lib/shoulda/matchers/integrations/test_frameworks/active_support_test_case.rb +1 -1
  79. data/lib/shoulda/matchers/integrations/test_frameworks/minitest_4.rb +1 -1
  80. data/lib/shoulda/matchers/integrations/test_frameworks/minitest_5.rb +1 -1
  81. data/lib/shoulda/matchers/integrations/test_frameworks/missing_test_framework.rb +1 -1
  82. data/lib/shoulda/matchers/integrations/test_frameworks/test_unit.rb +1 -1
  83. data/lib/shoulda/matchers/rails_shim.rb +5 -3
  84. data/lib/shoulda/matchers/util.rb +7 -2
  85. data/lib/shoulda/matchers/util/word_wrap.rb +7 -7
  86. data/lib/shoulda/matchers/version.rb +1 -1
  87. data/lib/shoulda/matchers/warn.rb +3 -3
  88. data/shoulda-matchers.gemspec +10 -7
  89. metadata +11 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f12034724c2954cf58fc7e89723ce42119e3a6f39676899c0510545a61f5fee
4
- data.tar.gz: 0c5cd62168c0dd00fa3246c9afe2ee4499db8c37312ff6f0f8ee10afb16f0f42
3
+ metadata.gz: '0268da0cff119fb6c9128b70f1826451b582bdc2495acf382f4e512a6636d0c8'
4
+ data.tar.gz: bf0698ed7605d8a8ef6b7e78bdc198bfa9502e1f2df134e3c5f524d1809b82da
5
5
  SHA512:
6
- metadata.gz: 3e33ed5061a6913d3b448f2f251e79a7618c9226275a308bf5a0547a81dddb4fbaf17a8834ddf3a1e3662cc712afaf6994bb9ea44a727adcdffbd41653ced13c
7
- data.tar.gz: e7ca6969c599eeb2fa8a084a4486085b6156760d0a77a1466d3989c0a9f15b7b092d7cdb7f4e2bbdf1befd5437afbd69121316e2ba6d9b271c809e3abfad82d1
6
+ metadata.gz: 407cc79fc367dd4f02b346a199a8d9a9c4ecc5f2d814b98b25989489d96fd2d02308459e2d3a086aeacd67cbd5a9e91e7e237f3fe04efb64c196307dd53abe71
7
+ data.tar.gz: a4eb04356408c22c7606ef403e1d4a042461e5323a9459875ad6a67f9f5cbc2944dee295d6086e6f1bea5b1d4fd7cace0fc5b701a4ba0199c75f7f002939f47a
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2006-2021 Tammer Saleh and thoughtbot, inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Shoulda Matchers [![Gem Version][version-badge]][rubygems] [![Build Status][travis-badge]][travis] [![Total Downloads][downloads-total]][rubygems] [![Downloads][downloads-badge]][rubygems] [![Hound][hound-badge]][hound]
1
+ # Shoulda Matchers [![Gem Version][version-badge]][rubygems] [![Build Status][travis-badge]][travis] [![Total Downloads][downloads-total]][rubygems] [![Downloads][downloads-badge]][rubygems]
2
2
 
3
3
  [version-badge]: https://img.shields.io/gem/v/shoulda-matchers.svg
4
4
  [rubygems]: https://rubygems.org/gems/shoulda-matchers
@@ -7,8 +7,6 @@
7
7
  [downloads-total]: https://img.shields.io/gem/dt/shoulda-matchers.svg
8
8
  [downloads-badge]: https://img.shields.io/gem/dtv/shoulda-matchers.svg
9
9
  [downloads-badge]: https://img.shields.io/gem/dtv/shoulda-matchers.svg
10
- [hound-badge]: https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg
11
- [hound]: https://houndci.com
12
10
 
13
11
  [![shoulda-matchers][logo]][website]
14
12
 
@@ -24,7 +22,7 @@ complex, and error-prone.
24
22
  📖 **[Read the documentation for the latest version][rubydocs].**
25
23
  📢 **[See what's changed in recent versions][changelog].**
26
24
 
27
- [rubydocs]: http://matchers.shoulda.io/docs
25
+ [rubydocs]: https://matchers.shoulda.io/docs
28
26
  [changelog]: CHANGELOG.md
29
27
 
30
28
  ## Table of contents
@@ -385,7 +383,7 @@ about any of them, make sure to [consult the documentation][rubydocs]!
385
383
  tests your `belongs_to` associations.
386
384
  * **[define_enum_for](lib/shoulda/matchers/active_record/define_enum_for_matcher.rb)**
387
385
  tests usage of the `enum` macro.
388
- * **[have_and_belong_to_many](lib/shoulda/matchers/active_record/association_matcher.rb)**
386
+ * **[have_and_belong_to_many](lib/shoulda/matchers/active_record/association_matcher.rb#L827)**
389
387
  tests your `has_and_belongs_to_many` associations.
390
388
  * **[have_db_column](lib/shoulda/matchers/active_record/have_db_column_matcher.rb)**
391
389
  tests that the table that backs your model has a specific column.
@@ -393,11 +391,11 @@ about any of them, make sure to [consult the documentation][rubydocs]!
393
391
  tests that the table that backs your model has an index on a specific column.
394
392
  * **[have_implicit_order_column](lib/shoulda/matchers/active_record/have_implicit_order_column.rb)**
395
393
  tests usage of `implicit_order_column`.
396
- * **[have_many](lib/shoulda/matchers/active_record/association_matcher.rb)**
394
+ * **[have_many](lib/shoulda/matchers/active_record/association_matcher.rb#L328)**
397
395
  tests your `has_many` associations.
398
396
  * **[have_many_attached](lib/shoulda/matchers/active_record/have_attached_matcher.rb)**
399
397
  tests your `has_many_attached` associations.
400
- * **[have_one](lib/shoulda/matchers/active_record/association_matcher.rb)**
398
+ * **[have_one](lib/shoulda/matchers/active_record/association_matcher.rb#L598)**
401
399
  tests your `has_one` associations.
402
400
  * **[have_one_attached](lib/shoulda/matchers/active_record/have_attached_matcher.rb)**
403
401
  tests your `has_one_attached` associations.
@@ -480,7 +478,7 @@ For Ruby < 2.4 and Rails < 4.1 compatibility, please use [v3.1.3][v3.1.3].
480
478
  ## Versioning
481
479
 
482
480
  Shoulda Matchers follows Semantic Versioning 2.0 as defined at
483
- <http://semver.org>.
481
+ <https://semver.org>.
484
482
 
485
483
  ## Team
486
484
 
@@ -492,7 +490,7 @@ Albuk][guialbuk].
492
490
 
493
491
  ## Copyright/License
494
492
 
495
- Shoulda Matchers is copyright © 2006-2020 Tammer Saleh and [thoughtbot,
493
+ Shoulda Matchers is copyright © 2006-2021 Tammer Saleh and [thoughtbot,
496
494
  inc][thoughtbot-website]. It is free and opensource software and may be
497
495
  redistributed under the terms specified in the [LICENSE](LICENSE) file.
498
496
 
@@ -179,11 +179,13 @@ module Shoulda
179
179
  end
180
180
 
181
181
  def failure_message
182
- "Expected that #{controller_class.name} would have :#{method_name} as a #{kind}_#{callback_type}"
182
+ "Expected that #{controller_class.name} would have :#{method_name}"\
183
+ " as a #{kind}_#{callback_type}"
183
184
  end
184
185
 
185
186
  def failure_message_when_negated
186
- "Expected that #{controller_class.name} would not have :#{method_name} as a #{kind}_#{callback_type}"
187
+ "Expected that #{controller_class.name} would not have"\
188
+ " :#{method_name} as a #{kind}_#{callback_type}"
187
189
  end
188
190
 
189
191
  def description
@@ -31,12 +31,13 @@ module Shoulda
31
31
  @key = key
32
32
  end
33
33
 
34
- def matches?(controller)
34
+ def matches?(_controller)
35
35
  filters_key?
36
36
  end
37
37
 
38
38
  def failure_message
39
- "Expected #{@key} to be filtered; filtered keys: #{filtered_keys.join(', ')}"
39
+ "Expected #{@key} to be filtered; filtered keys:"\
40
+ " #{filtered_keys.join(', ')}"
40
41
  end
41
42
 
42
43
  def failure_message_when_negated
@@ -209,7 +209,8 @@ module Shoulda
209
209
  attr_writer :stubbed_params
210
210
 
211
211
  def initialize(expected_permitted_parameter_names)
212
- @expected_permitted_parameter_names = expected_permitted_parameter_names
212
+ @expected_permitted_parameter_names =
213
+ expected_permitted_parameter_names
213
214
  @action = nil
214
215
  @verb = nil
215
216
  @request_params = {}
@@ -262,18 +263,20 @@ module Shoulda
262
263
  end
263
264
 
264
265
  def failure_message
265
- "Expected #{verb.upcase} ##{action} to #{expectation},\nbut #{reality}."
266
+ "Expected #{verb.upcase} ##{action} to #{expectation},"\
267
+ "\nbut #{reality}."
266
268
  end
267
269
 
268
270
  def failure_message_when_negated
269
- "Expected #{verb.upcase} ##{action} not to #{expectation},\nbut it did."
271
+ "Expected #{verb.upcase} ##{action} not to #{expectation},"\
272
+ "\nbut it did."
270
273
  end
271
274
 
272
275
  protected
273
276
 
274
- attr_reader :controller, :double_collections_by_parameter_name, :action, :verb,
275
- :request_params, :expected_permitted_parameter_names, :context, :subparameter_name,
276
- :parameters_double_registry
277
+ attr_reader :controller, :double_collections_by_parameter_name, :action,
278
+ :verb, :request_params, :expected_permitted_parameter_names,
279
+ :context, :subparameter_name, :parameters_double_registry
277
280
 
278
281
  def expectation
279
282
  message = 'restrict parameters '
@@ -282,7 +285,8 @@ module Shoulda
282
285
  message << "on #{subparameter_name.inspect} "
283
286
  end
284
287
 
285
- message << 'to ' + format_parameter_names(expected_permitted_parameter_names)
288
+ message << 'to '\
289
+ "#{format_parameter_names(expected_permitted_parameter_names)}"
286
290
 
287
291
  message
288
292
  end
@@ -291,9 +295,9 @@ module Shoulda
291
295
  if actual_permitted_parameter_names.empty?
292
296
  'it did not restrict any parameters'
293
297
  else
294
- 'the restricted parameters were ' +
295
- format_parameter_names(actual_permitted_parameter_names) +
296
- ' instead'
298
+ 'the restricted parameters were '\
299
+ "#{format_parameter_names(actual_permitted_parameter_names)}"\
300
+ ' instead'
297
301
  end
298
302
  end
299
303
 
@@ -303,12 +307,12 @@ module Shoulda
303
307
 
304
308
  def actual_permitted_parameter_names
305
309
  @_actual_permitted_parameter_names ||= begin
306
- if subparameter_name
307
- options = { for: subparameter_name }
308
- else
309
- options = {}
310
- end
311
-
310
+ options =
311
+ if subparameter_name
312
+ { for: subparameter_name }
313
+ else
314
+ {}
315
+ end
312
316
  parameters_double_registry.permitted_parameter_names(options)
313
317
  end
314
318
  end
@@ -329,8 +333,8 @@ module Shoulda
329
333
 
330
334
  def default_verb
331
335
  case action
332
- when :create then :post
333
- when :update then RailsShim.verb_for_update
336
+ when :create then :post
337
+ when :update then RailsShim.verb_for_update
334
338
  end
335
339
  end
336
340
 
@@ -346,7 +350,7 @@ module Shoulda
346
350
 
347
351
  def register
348
352
  double_collection = Doublespeak.double_collection_for(
349
- ::ActionController::Parameters.singleton_class
353
+ ::ActionController::Parameters.singleton_class,
350
354
  )
351
355
  double_collection.register_proxy(:new).to_return do |call|
352
356
  params = call.return_value
@@ -389,7 +393,7 @@ module Shoulda
389
393
 
390
394
  if double_collections_by_parameter_name.key?(subparameter_name)
391
395
  self.class.permitted_parameter_names_within(
392
- double_collections_by_parameter_name[subparameter_name]
396
+ double_collections_by_parameter_name[subparameter_name],
393
397
  )
394
398
  else
395
399
  []
@@ -436,7 +440,8 @@ module Shoulda
436
440
  # @private
437
441
  class VerbNotDefinedError < StandardError
438
442
  def message
439
- 'You must specify an HTTP verb when using a non-RESTful action. For example: for(:authorize, verb: :post)'
443
+ 'You must specify an HTTP verb when using a non-RESTful action.'\
444
+ ' For example: for(:authorize, verb: :post)'
440
445
  end
441
446
  end
442
447
  end
@@ -75,14 +75,12 @@ module Shoulda
75
75
  private
76
76
 
77
77
  def redirects_to_url?
78
- begin
79
- @context.__send__(:assert_redirected_to, url)
80
- @failure_message_when_negated = "Didn't expect to redirect to #{url}"
81
- true
82
- rescue Shoulda::Matchers.assertion_exception_class => error
83
- @failure_message = error.message
84
- false
85
- end
78
+ @context.__send__(:assert_redirected_to, url)
79
+ @failure_message_when_negated = "Didn't expect to redirect to #{url}"
80
+ true
81
+ rescue Shoulda::Matchers.assertion_exception_class => e
82
+ @failure_message = e.message
83
+ false
86
84
  end
87
85
 
88
86
  def url
@@ -71,14 +71,12 @@ module Shoulda
71
71
  private
72
72
 
73
73
  def renders_template?
74
- begin
75
- @context.__send__(:assert_template, @options, @message)
76
- @failure_message_when_negated = "Didn't expect to render #{@template}"
77
- true
78
- rescue Shoulda::Matchers.assertion_exception_class => error
79
- @failure_message = error.message
80
- false
81
- end
74
+ @context.__send__(:assert_template, @options, @message)
75
+ @failure_message_when_negated = "Didn't expect to render #{@template}"
76
+ true
77
+ rescue Shoulda::Matchers.assertion_exception_class => e
78
+ @failure_message = e.message
79
+ false
82
80
  end
83
81
  end
84
82
  end
@@ -64,12 +64,12 @@ module Shoulda
64
64
  # @private
65
65
  class RenderWithLayoutMatcher
66
66
  def initialize(expected_layout)
67
- if expected_layout
68
- @expected_layout = expected_layout.to_s
69
- else
70
- @expected_layout = nil
71
- end
72
-
67
+ @expected_layout =
68
+ if expected_layout
69
+ expected_layout.to_s
70
+ else
71
+ nil
72
+ end
73
73
  @controller = nil
74
74
  end
75
75
 
@@ -95,11 +95,12 @@ module Shoulda
95
95
 
96
96
  def description
97
97
  description = 'render with '
98
- if @expected_layout.nil?
99
- description << 'a layout'
100
- else
101
- description << "the #{@expected_layout.inspect} layout"
102
- end
98
+ description <<
99
+ if @expected_layout.nil?
100
+ 'a layout'
101
+ else
102
+ "the #{@expected_layout.inspect} layout"
103
+ end
103
104
  description
104
105
  end
105
106
 
@@ -118,7 +119,9 @@ module Shoulda
118
119
  end
119
120
 
120
121
  def rendered_layouts
121
- recorded_layouts.keys.compact.map { |layout| layout.sub(%r{^layouts/}, '') }
122
+ recorded_layouts.keys.compact.map { |layout|
123
+ layout.sub(%r{^layouts/}, '')
124
+ }
122
125
  end
123
126
 
124
127
  def recorded_layouts
@@ -135,7 +138,7 @@ module Shoulda
135
138
 
136
139
  def result
137
140
  if rendered_with_layout?
138
- 'rendered with ' + rendered_layouts.map(&:inspect).join(', ')
141
+ "rendered with #{rendered_layouts.map(&:inspect).join(', ')}"
139
142
  else
140
143
  'rendered without a layout'
141
144
  end
@@ -79,7 +79,8 @@ module Shoulda
79
79
  end
80
80
 
81
81
  unless handler_exists?
82
- expectation << " but #{controller} does not respond to #{expected_method}"
82
+ expectation << " but #{controller} does not respond to"\
83
+ " #{expected_method}"
83
84
  end
84
85
  expectation
85
86
  end
@@ -177,13 +177,12 @@ module Shoulda
177
177
 
178
178
  def add_port_to_path(path, port)
179
179
  if port
180
- "http://example.com:#{port}" + path
180
+ "https://example.com:#{port}" + path
181
181
  else
182
182
  path
183
183
  end
184
184
  end
185
185
 
186
-
187
186
  def guess_controller_if_necessary(controller)
188
187
  params[:controller] ||= controller.controller_path
189
188
  end
@@ -195,11 +194,11 @@ module Shoulda
195
194
  params,
196
195
  )
197
196
  true
198
- rescue ::ActionController::RoutingError => error
199
- @failure_message = error.message
197
+ rescue ::ActionController::RoutingError => e
198
+ @failure_message = e.message
200
199
  false
201
- rescue Shoulda::Matchers.assertion_exception_class => error
202
- @failure_message = error.message
200
+ rescue Shoulda::Matchers.assertion_exception_class => e
201
+ @failure_message = e.message
203
202
  false
204
203
  end
205
204
  end
@@ -3,7 +3,7 @@ module Shoulda
3
3
  module ActionController
4
4
  # @private
5
5
  class RouteParams
6
- PARAMS_TO_SYMBOLIZE = %i{ format }
6
+ PARAMS_TO_SYMBOLIZE = %i{format}.freeze
7
7
 
8
8
  def initialize(args)
9
9
  @args = args
@@ -20,7 +20,9 @@ module Shoulda
20
20
  def to(expected_value = nil, &block)
21
21
  if block
22
22
  unless context_set?
23
- message = "When specifying a value as a block, a context must be specified beforehand, e.g., #{store.name}.in_context(context).to { ... }"
23
+ message = 'When specifying a value as a block, a context must be'\
24
+ ' specified beforehand,'\
25
+ " e.g., #{store.name}.in_context(context).to { ... }"
24
26
  raise ArgumentError, message
25
27
  end
26
28
 
@@ -42,12 +44,14 @@ module Shoulda
42
44
  end
43
45
 
44
46
  def failure_message
45
- "Expected #{controller.class} to #{expectation_description}, but it did not"
47
+ "Expected #{controller.class} to #{expectation_description},"\
48
+ ' but it did not'
46
49
  end
47
50
  alias_method :failure_message_for_should, :failure_message
48
51
 
49
52
  def failure_message_when_negated
50
- "Expected #{controller.class} not to #{expectation_description}, but it did"
53
+ "Expected #{controller.class} not to #{expectation_description},"\
54
+ ' but it did'
51
55
  end
52
56
  alias_method :failure_message_for_should_not,
53
57
  :failure_message_when_negated
@@ -81,18 +85,20 @@ module Shoulda
81
85
  def expectation_description
82
86
  string = 'set'
83
87
 
84
- if key_set?
85
- string << " #{store.name}[#{key.inspect}]"
86
- else
87
- string << " any key in #{store.name}"
88
- end
89
-
90
- if expected_value_set?
91
- if expected_value.is_a?(Regexp)
92
- string << " to a value matching #{expected_value.inspect}"
88
+ string <<
89
+ if key_set?
90
+ " #{store.name}[#{key.inspect}]"
93
91
  else
94
- string << " to #{expected_value.inspect}"
92
+ " any key in #{store.name}"
95
93
  end
94
+
95
+ if expected_value_set?
96
+ string <<
97
+ if expected_value.is_a?(Regexp)
98
+ " to a value matching #{expected_value.inspect}"
99
+ else
100
+ " to #{expected_value.inspect}"
101
+ end
96
102
  end
97
103
 
98
104
  string