rubocop-rspec 2.24.0 → 2.25.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cd039667fb1c9cab8a794b4d4d028a1acdef5cc9033aa37fd37b8ddc6fa00c0
4
- data.tar.gz: c80d4491b4e9d124346195d38f73a3b13d251a4259fa459783d6dbb471ed9925
3
+ metadata.gz: afb5cf0c88af50530fc023549eb7e9083db3ca2314553f1fca912ea2a3c47bdb
4
+ data.tar.gz: ba30f926d9cd3056e786f724140ac4358af527496b2e783fcc5c8e541adc9d13
5
5
  SHA512:
6
- metadata.gz: eccda68a017df50004a38d6e55c6fbabeef13fa20aa37941aec18042adcace438c5cdd6ef821daed30cd17cb2884af79bf2a882f7da875e7190ed437c2e061b9
7
- data.tar.gz: '0832c87dd57fba0540c7d624b6bf5e38046b8a9bdc7ee82ee1c1a065a7d4bd6ba3f7949da6a9592d01de3ad8406bd8cc8433d309717cd5993314eaeecac076bb'
6
+ metadata.gz: cd7955549b3b95b481eb5dea24b98f72e1b802546f8e090695a782a20b0ee8d1d0bcca9a6089f3a46718c5a14967de6c8473709ecea72d8aa5eae85e2cb5bd6f
7
+ data.tar.gz: 2beb193cf65884c363c2ece1a3a7ba5db39eecc3a579724bd39f29696ab29276def06261363b6a6290d378743e0b79d414e056b65f0a8a9e2e4215a417d9b978
data/CHANGELOG.md CHANGED
@@ -2,9 +2,19 @@
2
2
 
3
3
  ## Master (Unreleased)
4
4
 
5
+ ## 2.25.0 (2023-10-27)
6
+
7
+ - Add support single quoted string and percent string and heredoc for `RSpec/Rails/HttpStatus`. ([@ydah])
8
+ - Change to be inline disable for `RSpec/SpecFilePathFormat` like `RSpec/FilePath`. ([@ydah])
9
+ - Fix a false positive for `RSpec/MetadataStyle` with example groups having multiple string arguments. ([@franzliedke])
10
+
11
+ ## 2.24.1 (2023-09-23)
12
+
13
+ - Fix an error when using `RSpec/FilePath` and revert to enabled by default. If you have already moved to `RSpec/SpecFilePathSuffix` and `RSpec/SpecFilePathFormat`, disable `RSpec/FilePath` explicitly as `Enabled: false`. The `RSpec/FilePath` before migration and the `RSpec/SpecFilePathSuffix` and `RSpec/SpecFilePathFormat` as the target are available respectively. ([@ydah])
14
+
5
15
  ## 2.24.0 (2023-09-08)
6
16
 
7
- - Split `RSpec/FilePath` into `RSpec/SpecFilePathSuffix` and `RSpec/SpecFilePathFormat`. `RSpec/FilePath` cop is enabled by default, the two new cops are pending and need to be enabled explicitly. ([@ydah])
17
+ - Split `RSpec/FilePath` into `RSpec/SpecFilePathSuffix` and `RSpec/SpecFilePathFormat`. `RSpec/FilePath` cop is disabled by default and the two new cops are pending and need to be enabled explicitly. ([@ydah])
8
18
  - Add new `RSpec/Eq` cop. ([@ydah])
9
19
  - Add `RSpec/MetadataStyle` and `RSpec/EmptyMetadata` cops. ([@r7kamura])
10
20
  - Add support `RSpec/Rails/HttpStatus` when `have_http_status` with string argument. ([@ydah])
@@ -19,7 +29,7 @@
19
29
 
20
30
  ## 2.23.1 (2023-08-07)
21
31
 
22
- - Mark to `Safe: false` for `RSpec/Rails/NegationBeValid` cop. ([@ydah])
32
+ - Mark to `Safe: false` for `RSpec/Rails/NegationBeValid` cop. ([@ydah])
23
33
  - Declare autocorrect as unsafe for `RSpec/ReceiveMessages`. ([@bquorning])
24
34
 
25
35
  ## 2.23.0 (2023-07-30)
@@ -28,13 +38,13 @@
28
38
  - Fix a false negative for `RSpec/ExcessiveDocstringSpacing` when finds description with em space. ([@ydah])
29
39
  - Fix a false positive for `RSpec/EmptyExampleGroup` when example group with examples defined in `if` branch inside iterator. ([@ydah])
30
40
  - Update the message output of `RSpec/ExpectActual` to include the word 'value'. ([@corydiamand])
31
- - Fix a false negative for `RSpec/Pending` when `it` without body. ([@ydah])
41
+ - Fix a false negative for `RSpec/Pending` when `it` without body. ([@ydah])
32
42
  - Add new `RSpec/ReceiveMessages` cop. ([@ydah])
33
43
  - Change default.yml path to use `**/spec/*` instead of `spec/*`. ([@ydah])
34
- - Add `AllowedIdentifiers` and `AllowedPatterns` configuration option to `RSpec/IndexedLet`. ([@ydah])
44
+ - Add `AllowedIdentifiers` and `AllowedPatterns` configuration option to `RSpec/IndexedLet`. ([@ydah])
35
45
  - Fix `RSpec/NamedSubject` when block has no body. ([@splattael])
36
46
  - Fix `RSpec/LetBeforeExamples` autocorrect incompatible with `RSpec/ScatteredLet` autocorrect. ([@ydah])
37
- - Update `RSpec/Focus` to support `shared_context` and `shared_examples` ([@tmaier])
47
+ - Update `RSpec/Focus` to support `shared_context` and `shared_examples`. ([@tmaier])
38
48
 
39
49
  ## 2.22.0 (2023-05-06)
40
50
 
@@ -56,9 +66,9 @@
56
66
  - Add support `be_status` style for `RSpec/Rails/HttpStatus`. ([@ydah])
57
67
  - Add support for shared example groups to `RSpec/EmptyLineAfterExampleGroup`. ([@pirj])
58
68
  - Add support for `RSpec/HaveHttpStatus` when using `response.code`. ([@ydah])
59
- - Fix order of expected and actual in correction for `RSpec/Rails/MinitestAssertions` ([@mvz])
69
+ - Fix order of expected and actual in correction for `RSpec/Rails/MinitestAssertions`. ([@mvz])
60
70
  - Fix a false positive for `RSpec/DescribedClassModuleWrapping` when RSpec.describe numblock is nested within a module. ([@ydah])
61
- - Fix a false positive for `RSpec/FactoryBot/ConsistentParenthesesStyle` inside `&&`, `||` and `:?` when `omit_parentheses` is on ([@dmitrytsepelev])
71
+ - Fix a false positive for `RSpec/FactoryBot/ConsistentParenthesesStyle` inside `&&`, `||` and `:?` when `omit_parentheses` is on. ([@dmitrytsepelev])
62
72
  - Fix a false positive for `RSpec/PendingWithoutReason` when pending/skip has a reason inside an example group. ([@ydah])
63
73
  - Fix a false negative for `RSpec/RedundantAround` when redundant numblock `around`. ([@ydah])
64
74
  - Change `RSpec/ContainExactly` to ignore calls with no arguments, and change `RSpec/MatchArray` to ignore calls with an empty array literal argument. ([@ydah], [@bquorning])
@@ -111,7 +121,7 @@
111
121
  - Improved processing speed for `RSpec/Be`, `RSpec/ExpectActual`, `RSpec/ImplicitExpect`, `RSpec/MessageSpies`, `RSpec/PredicateMatcher` and `RSpec/Rails/HaveHttpStatus`. ([@ydah])
112
122
  - Fix wrong autocorrection in `n_times` style on `RSpec/FactoryBot/CreateList`. ([@r7kamura])
113
123
  - Fix a false positive for `RSpec/FactoryBot/ConsistentParenthesesStyle` when using `generate` with multiple arguments. ([@ydah])
114
- - Mark `RSpec/BeEq` as `Safe: false` ([@r7kamura])
124
+ - Mark `RSpec/BeEq` as `Safe: false`. ([@r7kamura])
115
125
  - Add `RSpec/DuplicatedMetadata` cop. ([@r7kamura])
116
126
  - Mark `RSpec/BeEql` as `Safe: false`. ([@r7kamura])
117
127
  - Add `RSpec/PendingWithoutReason` cop. ([@r7kamura])
@@ -144,8 +154,8 @@
144
154
  - Fix a false positive for `RSpec/Capybara/SpecificMatcher` when `have_css("a")` without attribute. ([@ydah])
145
155
  - Update `RSpec/ExampleWording` cop to raise error for insufficient descriptions. ([@akrox58])
146
156
  - Add new `RSpec/Capybara/NegationMatcher` cop. ([@ydah])
147
- - Add `AllowedPatterns` configuration option to `RSpec/NoExpectationExample`. ([@ydah])
148
- - Improve `RSpec/NoExpectationExample` cop to ignore examples skipped or pending via metadata. ([@pirj])
157
+ - Add `AllowedPatterns` configuration option to `RSpec/NoExpectationExample`. ([@ydah])
158
+ - Improve `RSpec/NoExpectationExample` cop to ignore examples skipped or pending via metadata. ([@pirj])
149
159
  - Add `RSpec/FactoryBot/ConsistentParenthesesStyle` cop. ([@Liberatys])
150
160
  - Add `RSpec/Rails/InferredSpecType` cop. ([@r7kamura])
151
161
  - Add new `RSpec/Capybara/SpecificActions` cop. ([@ydah])
@@ -461,7 +471,7 @@
461
471
  - Add config to `RSpec/VerifiedDoubles` to enforcement of verification on unnamed doubles. ([@BrentWheeldon])
462
472
  - Fix `FactoryBot/AttributeDefinedStatically` not working when there is a non-symbol key. ([@vzvu3k6k])
463
473
  - Fix false positive in `RSpec/ImplicitSubject` when `is_expected` is used inside `its()` block. ([@Darhazer])
464
- - Add `single_statement_only` style to `RSpec/ImplicitSubject` as a more relaxed alternative to `single_line_only`. ([@Darhazer])
474
+ - Add `single_statement_only` style to `RSpec/ImplicitSubject` as a more relaxed alternative to `single_line_only`. ([@Darhazer])
465
475
  - Add `RSpec/UnspecifiedException` as a default cop to encourage more-specific `expect{}.to raise_error(ExceptionType)`, or `raise_exception` style handling of exceptions. ([@daveworth])
466
476
 
467
477
  ## 1.29.1 (2018-09-01)
@@ -496,14 +506,14 @@
496
506
 
497
507
  ## 1.26.0 (2018-06-06)
498
508
 
499
- - Fix false positive in `RSpec/EmptyExampleGroup` cop when methods named like a RSpec method are used. ([@Darhazer])
509
+ - Fix false positive in `RSpec/EmptyExampleGroup` cop when methods named like a RSpec method are used. ([@Darhazer])
500
510
  - Fix `Capybara/FeatureMethods` not working when there is require before the spec. ([@Darhazer])
501
511
  - Fix `RSpec/EmptyLineAfterFinalLet`: allow a comment to be placed after latest let, requiring empty line after the comment. ([@Darhazer])
502
512
  - Add `RSpec/ReceiveCounts` cop to enforce usage of :once and :twice matchers. ([@Darhazer])
503
513
 
504
514
  ## 1.25.1 (2018-04-10)
505
515
 
506
- - Fix false positive in `RSpec/Pending` cop when pending is used as a method name. ([@Darhazer])
516
+ - Fix false positive in `RSpec/Pending` cop when pending is used as a method name. ([@Darhazer])
507
517
  - Fix `FactoryBot/DynamicAttributeDefinedStatically` false positive when using symbol proc argument for a sequence. ([@tdeo])
508
518
 
509
519
  ## 1.25.0 (2018-04-07)
@@ -511,7 +521,7 @@
511
521
  - Add `RSpec/SharedExamples` cop to enforce consistent usage of string to titleize shared examples. ([@anthony-robin])
512
522
  - Add `RSpec/Be` cop to enforce passing argument to the generic `be` matcher. ([@Darhazer])
513
523
  - Fix false positives in `StaticAttributeDefinedDynamically` and `ReturnFromStub` when a const is used in an array or hash. ([@Darhazer])
514
- - Add `RSpec/Pending` cop to enforce no existing pending or skipped examples. This is disabled by default. ([@patrickomatic])
524
+ - Add `RSpec/Pending` cop to enforce no existing pending or skipped examples. This is disabled by default. ([@patrickomatic])
515
525
  - Fix `RSpec/NestedGroups` cop support --auto-gen-config. ([@walf443])
516
526
  - Fix false positives in `Capybara/FeatureMethods` when feature methods are used as property names in a factory. ([@Darhazer])
517
527
  - Allow configuring enabled methods in `Capybara/FeatureMethods`. ([@Darhazer])
@@ -835,6 +845,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
835
845
  [@faucct]: https://github.com/faucct
836
846
  [@foton]: https://github.com/foton
837
847
  [@francois-ferrandis]: https://github.com/francois-ferrandis
848
+ [@franzliedke]: https://github.com/franzliedke
838
849
  [@g-rath]: https://github.com/G-Rath
839
850
  [@geniou]: https://github.com/geniou
840
851
  [@gsamokovarov]: https://github.com/gsamokovarov
data/config/default.yml CHANGED
@@ -448,7 +448,7 @@ RSpec/ExpectOutput:
448
448
 
449
449
  RSpec/FilePath:
450
450
  Description: Checks that spec file paths are consistent and well-formed.
451
- Enabled: false
451
+ Enabled: true
452
452
  Include:
453
453
  - "**/*_spec*rb*"
454
454
  - "**/spec/**/*"
@@ -27,9 +27,3 @@ renamed:
27
27
  RSpec/FactoryBot/FactoryClassName: FactoryBot/FactoryClassName
28
28
  RSpec/FactoryBot/FactoryNameStyle: FactoryBot/FactoryNameStyle
29
29
  RSpec/FactoryBot/SyntaxMethods: FactoryBot/SyntaxMethods
30
-
31
- split:
32
- RSpec/FilePath:
33
- alternatives:
34
- - RSpec/SpecFilePathFormat
35
- - RSpec/SpecFilePathSuffix
@@ -26,11 +26,12 @@ module RuboCop
26
26
  # expect(result).to be(true)
27
27
  # end
28
28
  #
29
- # You can set literals you want to fold with `CountAsOne`.
30
- # Available are: 'array', 'hash', and 'heredoc'. Each literal
31
- # will be counted as one line regardless of its actual size.
29
+ # You can set constructs you want to fold with `CountAsOne`.
30
+ # Available are: 'array', 'hash', 'heredoc', and 'method_call'.
31
+ # Each construct will be counted as one line regardless of
32
+ # its actual size.
32
33
  #
33
- # @example CountAsOne: ['array', 'heredoc']
34
+ # @example CountAsOne: ['array', 'heredoc', 'method_call']
34
35
  #
35
36
  # it do
36
37
  # array = [ # +1
@@ -46,7 +47,12 @@ module RuboCop
46
47
  # Heredoc
47
48
  # content.
48
49
  # HEREDOC
49
- # end # 5 points
50
+ #
51
+ # foo( # +1
52
+ # 1,
53
+ # 2
54
+ # )
55
+ # end # 6 points
50
56
  #
51
57
  class ExampleLength < Base
52
58
  include CodeLength
@@ -5,6 +5,12 @@ module RuboCop
5
5
  module RSpec
6
6
  # Checks that spec file paths are consistent and well-formed.
7
7
  #
8
+ # This cop is deprecated.
9
+ # We plan to remove it in the next major version update to 3.0.
10
+ # The migration targets are `RSpec/SpecFilePathSuffix`
11
+ # and `RSpec/SpecFilePathFormat`.
12
+ # If you are using this cop, please plan for migration.
13
+ #
8
14
  # By default, this checks that spec file paths are consistent with the
9
15
  # test subject and enforces that it reflects the described
10
16
  # class/module and its optionally called out method.
@@ -45,6 +45,11 @@ module RuboCop
45
45
  PATTERN
46
46
 
47
47
  def on_metadata(symbols, hash)
48
+ # RSpec example groups accept two string arguments. In such a case,
49
+ # the rspec_metadata matcher will interpret the second string
50
+ # argument as a metadata symbol.
51
+ symbols.shift if symbols.first&.str_type?
52
+
48
53
  symbols.each do |symbol|
49
54
  on_metadata_symbol(symbol)
50
55
  end
@@ -30,12 +30,12 @@ module RuboCop
30
30
  def on_block(node)
31
31
  rspec_configure(node) do |block_var|
32
32
  metadata_in_block(node, block_var) do |metadata_arguments|
33
- on_matadata_arguments(metadata_arguments)
33
+ on_metadata_arguments(metadata_arguments)
34
34
  end
35
35
  end
36
36
 
37
37
  rspec_metadata(node) do |metadata_arguments|
38
- on_matadata_arguments(metadata_arguments)
38
+ on_metadata_arguments(metadata_arguments)
39
39
  end
40
40
  end
41
41
  alias on_numblock on_block
@@ -46,7 +46,7 @@ module RuboCop
46
46
 
47
47
  private
48
48
 
49
- def on_matadata_arguments(metadata_arguments)
49
+ def on_metadata_arguments(metadata_arguments)
50
50
  *symbols, last = metadata_arguments
51
51
  hash = nil
52
52
  case last&.type
@@ -66,6 +66,8 @@ module RuboCop
66
66
 
67
67
  def on_send(node)
68
68
  http_status(node) do |arg|
69
+ return if arg.str_type? && arg.heredoc?
70
+
69
71
  checker = checker_class.new(arg)
70
72
  return unless checker.offensive?
71
73
 
@@ -105,6 +107,10 @@ module RuboCop
105
107
  format(MSG, prefer: prefer, current: current)
106
108
  end
107
109
 
110
+ def current
111
+ offense_range.source
112
+ end
113
+
108
114
  def offense_range
109
115
  node
110
116
  end
@@ -129,10 +135,6 @@ module RuboCop
129
135
  symbol.inspect
130
136
  end
131
137
 
132
- def current
133
- node.value.inspect
134
- end
135
-
136
138
  private
137
139
 
138
140
  def symbol
@@ -140,7 +142,7 @@ module RuboCop
140
142
  end
141
143
 
142
144
  def number
143
- node.source.delete('"').to_i
145
+ node.value.to_i
144
146
  end
145
147
  end
146
148
 
@@ -154,10 +156,6 @@ module RuboCop
154
156
  number.to_s
155
157
  end
156
158
 
157
- def current
158
- symbol.inspect
159
- end
160
-
161
159
  private
162
160
 
163
161
  def symbol
@@ -190,10 +188,6 @@ module RuboCop
190
188
  end
191
189
  end
192
190
 
193
- def current
194
- offense_range.source
195
- end
196
-
197
191
  private
198
192
 
199
193
  def symbol
@@ -201,15 +195,15 @@ module RuboCop
201
195
  end
202
196
 
203
197
  def number
204
- node.source.to_i
198
+ node.value.to_i
205
199
  end
206
200
 
207
201
  def normalize_str
208
- normalized = node.source.delete('"')
209
- if normalized.match?(/\A\d+\z/)
210
- ::Rack::Utils::SYMBOL_TO_STATUS_CODE.key(normalized.to_i)
202
+ str = node.value.to_s
203
+ if str.match?(/\A\d+\z/)
204
+ ::Rack::Utils::SYMBOL_TO_STATUS_CODE.key(str.to_i)
211
205
  else
212
- normalized
206
+ str
213
207
  end
214
208
  end
215
209
  end
@@ -41,7 +41,7 @@ module RuboCop
41
41
 
42
42
  # @!method example_group_arguments(node)
43
43
  def_node_matcher :example_group_arguments, <<~PATTERN
44
- (block (send #rspec? #ExampleGroups.all $_ $...) ...)
44
+ (block $(send #rspec? #ExampleGroups.all $_ $...) ...)
45
45
  PATTERN
46
46
 
47
47
  # @!method metadata_key_value(node)
@@ -50,16 +50,16 @@ module RuboCop
50
50
  def on_top_level_example_group(node)
51
51
  return unless top_level_groups.one?
52
52
 
53
- example_group_arguments(node) do |class_name, arguments|
53
+ example_group_arguments(node) do |send_node, class_name, arguments|
54
54
  next if !class_name.const_type? || ignore_metadata?(arguments)
55
55
 
56
- ensure_correct_file_path(class_name, arguments)
56
+ ensure_correct_file_path(send_node, class_name, arguments)
57
57
  end
58
58
  end
59
59
 
60
60
  private
61
61
 
62
- def ensure_correct_file_path(class_name, arguments)
62
+ def ensure_correct_file_path(send_node, class_name, arguments)
63
63
  pattern = correct_path_pattern(class_name, arguments)
64
64
  return if filename_ends_with?(pattern)
65
65
 
@@ -67,7 +67,7 @@ module RuboCop
67
67
  # expression pattern to resemble a glob pattern for clearer error
68
68
  # messages.
69
69
  suffix = pattern.sub('.*', '*').sub('[^/]*', '*').sub('\.', '.')
70
- add_global_offense(format(MSG, suffix: suffix))
70
+ add_offense(send_node, message: format(MSG, suffix: suffix))
71
71
  end
72
72
 
73
73
  def ignore_metadata?(arguments)
@@ -52,7 +52,7 @@ module RuboCop
52
52
  return true unless parent
53
53
  return true if parent.begin_type?
54
54
 
55
- true if parent.block_type? && parent.body == expect
55
+ parent.block_type? && parent.body == expect
56
56
  end
57
57
  end
58
58
  end
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module RSpec
5
5
  # Version information for the RSpec RuboCop plugin.
6
6
  module Version
7
- STRING = '2.24.0'
7
+ STRING = '2.25.0'
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.24.0
4
+ version: 2.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Backus
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-09-08 00:00:00.000000000 Z
13
+ date: 2023-10-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '1.33'
21
+ version: '1.40'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: '1.33'
28
+ version: '1.40'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rubocop-capybara
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -249,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0'
251
251
  requirements: []
252
- rubygems_version: 3.4.12
252
+ rubygems_version: 3.4.17
253
253
  signing_key:
254
254
  specification_version: 4
255
255
  summary: Code style checking for RSpec files