rubocop-rspec 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +13 -0
- data/config/obsoletion.yml +5 -22
- data/lib/rubocop/cop/rspec/example_wording.rb +2 -2
- data/lib/rubocop/cop/rspec/multiple_expectations.rb +2 -2
- data/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb +2 -1
- data/lib/rubocop/cop/rspec/nested_groups.rb +2 -1
- data/lib/rubocop/cop/rspec/predicate_matcher.rb +7 -3
- data/lib/rubocop/cop/rspec/scattered_setup.rb +7 -1
- data/lib/rubocop/rspec/version.rb +1 -1
- data/lib/rubocop/rspec/wording.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc86eb0b71fda4e28260323fd53987730be73074de0011d50c43429f8de531e0
|
|
4
|
+
data.tar.gz: 2b65f66de5fb68f06f752227a5c2376a4680a1984b5f21880b35325031160d24
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 835a6f93ad56ee749027bfcfa9f717a6c92ec5ab3fbbd2c0e47a5ddcad89de0f80381d06635e82d7c6c55f7d22d0b3a39dd514e02ae5dc3b840e5023070485da
|
|
7
|
+
data.tar.gz: '093d0cb926c5e3c5d2f0aaab4b56f2e6855dca2dd40200590cb4629dbd448450bca32c0c3c7e40102518f92b30574481f6a06c69e738e776bb5ca268be2649ce'
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## Master (Unreleased)
|
|
4
4
|
|
|
5
|
+
## 3.0.3 (2024-07-12)
|
|
6
|
+
|
|
7
|
+
- Add support for Unicode RIGHT SINGLE QUOTATION MARK in `RSpec/ExampleWording`. ([@jdufresne])
|
|
8
|
+
- Suppress deprecation warning for `RSpec/MultipleExpectations`, `RSpec/MultipleMemoizedHelpers`, and `RSpec/NestedGroups` cops. ([@koic])
|
|
9
|
+
|
|
10
|
+
## 3.0.2 (2024-07-02)
|
|
11
|
+
|
|
12
|
+
- Fix wrong autocorrect for `RSpec/ScatteredSetup` when hook contains heredoc. ([@earlopain])
|
|
13
|
+
- Fix false negative for `RSpec/PredicateMatcher` when expectation contains custom failure message. ([@earlopain])
|
|
14
|
+
- Facilitate the 3.0 upgrade flow with proper extracted cop messages. ([@jeppester])
|
|
15
|
+
|
|
5
16
|
## 3.0.1 (2024-06-11)
|
|
6
17
|
|
|
7
18
|
- Bump RuboCop requirement to +1.61. ([@ydah])
|
|
@@ -933,6 +944,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
|
933
944
|
[@jaredmoody]: https://github.com/jaredmoody
|
|
934
945
|
[@jdufresne]: https://github.com/jdufresne
|
|
935
946
|
[@jeffreyc]: https://github.com/jeffreyc
|
|
947
|
+
[@jeppester]: https://github.com/jeppester
|
|
936
948
|
[@jessieay]: https://github.com/jessieay
|
|
937
949
|
[@jfragoulis]: https://github.com/jfragoulis
|
|
938
950
|
[@johnny-miyake]: https://github.com/johnny-miyake
|
data/README.md
CHANGED
|
@@ -7,6 +7,15 @@
|
|
|
7
7
|
[RSpec](https://rspec.info/)-specific analysis for your projects, as an extension to
|
|
8
8
|
[RuboCop](https://github.com/rubocop/rubocop).
|
|
9
9
|
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Upgrading to RuboCop RSpec v3.x](#upgrading-to-rubocop-rspec-v3x)
|
|
12
|
+
- [Upgrading to RuboCop RSpec v2.x](#upgrading-to-rubocop-rspec-v2x)
|
|
13
|
+
- [Usage](#usage)
|
|
14
|
+
- [Documentation](#documentation)
|
|
15
|
+
- [The Cops](#the-cops)
|
|
16
|
+
- [Contributing](#contributing)
|
|
17
|
+
- [License](#license)
|
|
18
|
+
|
|
10
19
|
## Installation
|
|
11
20
|
|
|
12
21
|
Just install the `rubocop-rspec` gem
|
|
@@ -21,6 +30,10 @@ or if you use bundler put this in your `Gemfile`
|
|
|
21
30
|
gem 'rubocop-rspec', require: false
|
|
22
31
|
```
|
|
23
32
|
|
|
33
|
+
### Upgrading to RuboCop RSpec v3.x
|
|
34
|
+
|
|
35
|
+
Read all the details in our [Upgrade to Version 3.x](https://docs.rubocop.org/rubocop-rspec/3.0/upgrade_to_version_3.html) document.
|
|
36
|
+
|
|
24
37
|
### Upgrading to RuboCop RSpec v2.x
|
|
25
38
|
|
|
26
39
|
Read all the details in our [Upgrade to Version 2.x](https://docs.rubocop.org/rubocop-rspec/2.0/upgrade_to_version_2.html) document.
|
data/config/obsoletion.yml
CHANGED
|
@@ -13,28 +13,6 @@ changed_parameters:
|
|
|
13
13
|
alternative: AllowedPatterns
|
|
14
14
|
severity: warning
|
|
15
15
|
|
|
16
|
-
renamed:
|
|
17
|
-
RSpec/Capybara/CurrentPathExpectation: Capybara/CurrentPathExpectation
|
|
18
|
-
RSpec/Capybara/MatchStyle: Capybara/MatchStyle
|
|
19
|
-
RSpec/Capybara/NegationMatcher: Capybara/NegationMatcher
|
|
20
|
-
RSpec/Capybara/SpecificActions: Capybara/SpecificActions
|
|
21
|
-
RSpec/Capybara/SpecificFinders: Capybara/SpecificFinders
|
|
22
|
-
RSpec/Capybara/SpecificMatcher: Capybara/SpecificMatcher
|
|
23
|
-
RSpec/Capybara/VisibilityMatcher: Capybara/VisibilityMatcher
|
|
24
|
-
RSpec/FactoryBot/AttributeDefinedStatically: FactoryBot/AttributeDefinedStatically
|
|
25
|
-
RSpec/FactoryBot/ConsistentParenthesesStyle: FactoryBot/ConsistentParenthesesStyle
|
|
26
|
-
RSpec/FactoryBot/CreateList: FactoryBot/CreateList
|
|
27
|
-
RSpec/FactoryBot/FactoryClassName: FactoryBot/FactoryClassName
|
|
28
|
-
RSpec/FactoryBot/FactoryNameStyle: FactoryBot/FactoryNameStyle
|
|
29
|
-
RSpec/FactoryBot/SyntaxMethods: FactoryBot/SyntaxMethods
|
|
30
|
-
RSpec/Rails/AvoidSetupHook: RSpecRails/AvoidSetupHook
|
|
31
|
-
RSpec/Rails/HaveHttpStatus: RSpecRails/HaveHttpStatus
|
|
32
|
-
RSpec/Rails/HttpStatus: RSpecRails/HttpStatus
|
|
33
|
-
RSpec/Rails/InferredSpecType: RSpecRails/InferredSpecType
|
|
34
|
-
RSpec/Rails/MinitestAssertions: RSpecRails/MinitestAssertions
|
|
35
|
-
RSpec/Rails/NegationBeValid: RSpecRails/NegationBeValid
|
|
36
|
-
RSpec/Rails/TravelAround: RSpecRails/TravelAround
|
|
37
|
-
|
|
38
16
|
split:
|
|
39
17
|
RSpec/FilePath:
|
|
40
18
|
alternatives:
|
|
@@ -45,3 +23,8 @@ removed:
|
|
|
45
23
|
RSpec/Capybara/FeatureMethods:
|
|
46
24
|
reason: >
|
|
47
25
|
this cop has migrated to `RSpec/Dialect`. Please use `RSpec/Dialect` instead
|
|
26
|
+
|
|
27
|
+
extracted:
|
|
28
|
+
RSpec/Rails/*: rubocop-rspec_rails
|
|
29
|
+
RSpec/FactoryBot/*: rubocop-factory_bot
|
|
30
|
+
RSpec/Capybara/*: rubocop-capybara
|
|
@@ -55,8 +55,8 @@ module RuboCop
|
|
|
55
55
|
MSG_INSUFFICIENT_DESCRIPTION = 'Your example description is ' \
|
|
56
56
|
'insufficient.'
|
|
57
57
|
|
|
58
|
-
SHOULD_PREFIX = /\Ashould(?:n't)?\b/i.freeze
|
|
59
|
-
WILL_PREFIX = /\A(?:will|won't)\b/i.freeze
|
|
58
|
+
SHOULD_PREFIX = /\Ashould(?:n't|n’t)?\b/i.freeze
|
|
59
|
+
WILL_PREFIX = /\A(?:will|won't|won’t)\b/i.freeze
|
|
60
60
|
IT_PREFIX = /\Ait /i.freeze
|
|
61
61
|
|
|
62
62
|
# @!method it_description(node)
|
|
@@ -67,13 +67,13 @@ module RuboCop
|
|
|
67
67
|
# end
|
|
68
68
|
#
|
|
69
69
|
class MultipleExpectations < Base
|
|
70
|
-
include ConfigurableMax
|
|
71
|
-
|
|
72
70
|
MSG = 'Example has too many expectations [%<total>d/%<max>d].'
|
|
73
71
|
|
|
74
72
|
ANYTHING = ->(_node) { true }
|
|
75
73
|
TRUE_NODE = lambda(&:true_type?)
|
|
76
74
|
|
|
75
|
+
exclude_limit 'Max'
|
|
76
|
+
|
|
77
77
|
# @!method aggregate_failures?(node)
|
|
78
78
|
def_node_matcher :aggregate_failures?, <<~PATTERN
|
|
79
79
|
(block {
|
|
@@ -82,11 +82,12 @@ module RuboCop
|
|
|
82
82
|
# end
|
|
83
83
|
#
|
|
84
84
|
class MultipleMemoizedHelpers < Base
|
|
85
|
-
include ConfigurableMax
|
|
86
85
|
include Variable
|
|
87
86
|
|
|
88
87
|
MSG = 'Example group has too many memoized helpers [%<count>d/%<max>d]'
|
|
89
88
|
|
|
89
|
+
exclude_limit 'Max'
|
|
90
|
+
|
|
90
91
|
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
|
|
91
92
|
return unless spec_group?(node)
|
|
92
93
|
|
|
@@ -92,7 +92,6 @@ module RuboCop
|
|
|
92
92
|
# end
|
|
93
93
|
#
|
|
94
94
|
class NestedGroups < Base
|
|
95
|
-
include ConfigurableMax
|
|
96
95
|
include TopLevelGroup
|
|
97
96
|
|
|
98
97
|
MSG = 'Maximum example group nesting exceeded [%<total>d/%<max>d].'
|
|
@@ -103,6 +102,8 @@ module RuboCop
|
|
|
103
102
|
"Configuration key `#{DEPRECATED_MAX_KEY}` for #{cop_name} is " \
|
|
104
103
|
'deprecated in favor of `Max`. Please use that instead.'
|
|
105
104
|
|
|
105
|
+
exclude_limit 'Max'
|
|
106
|
+
|
|
106
107
|
def on_top_level_group(node)
|
|
107
108
|
find_nested_example_groups(node) do |example_group, nesting|
|
|
108
109
|
self.max = nesting
|
|
@@ -32,7 +32,7 @@ module RuboCop
|
|
|
32
32
|
(block $(send !nil? #predicate? ...) ...)
|
|
33
33
|
$(send !nil? #predicate? ...)})
|
|
34
34
|
$#Runners.all
|
|
35
|
-
$#boolean_matcher?)
|
|
35
|
+
$#boolean_matcher? ...)
|
|
36
36
|
PATTERN
|
|
37
37
|
|
|
38
38
|
# @!method be_bool?(node)
|
|
@@ -183,8 +183,12 @@ module RuboCop
|
|
|
183
183
|
(send
|
|
184
184
|
(send nil? :expect $!nil?)
|
|
185
185
|
#Runners.all
|
|
186
|
-
{
|
|
187
|
-
|
|
186
|
+
{
|
|
187
|
+
$(send nil? #predicate_matcher_name? ...)
|
|
188
|
+
(block $(send nil? #predicate_matcher_name? ...) ...)
|
|
189
|
+
}
|
|
190
|
+
...
|
|
191
|
+
)
|
|
188
192
|
PATTERN
|
|
189
193
|
|
|
190
194
|
# @!method predicate_matcher_block?(node)
|
|
@@ -23,6 +23,7 @@ module RuboCop
|
|
|
23
23
|
# end
|
|
24
24
|
#
|
|
25
25
|
class ScatteredSetup < Base
|
|
26
|
+
include FinalEndLocation
|
|
26
27
|
include RangeHelp
|
|
27
28
|
extend AutoCorrector
|
|
28
29
|
|
|
@@ -75,8 +76,13 @@ module RuboCop
|
|
|
75
76
|
def autocorrect(corrector, first_occurrence, occurrence)
|
|
76
77
|
return if first_occurrence == occurrence || !first_occurrence.body
|
|
77
78
|
|
|
79
|
+
# Take heredocs into account
|
|
80
|
+
body = occurrence.body&.source_range&.with(
|
|
81
|
+
end_pos: final_end_location(occurrence).begin_pos
|
|
82
|
+
)
|
|
83
|
+
|
|
78
84
|
corrector.insert_after(first_occurrence.body,
|
|
79
|
-
"\n#{
|
|
85
|
+
"\n#{body&.source}")
|
|
80
86
|
corrector.remove(range_by_whole_lines(occurrence.source_range,
|
|
81
87
|
include_final_newline: true))
|
|
82
88
|
end
|
|
@@ -4,10 +4,10 @@ module RuboCop
|
|
|
4
4
|
module RSpec
|
|
5
5
|
# RSpec example wording rewriter
|
|
6
6
|
class Wording
|
|
7
|
-
SHOULDNT_PREFIX = /\Ashould(?:n't| not)\b/i.freeze
|
|
7
|
+
SHOULDNT_PREFIX = /\Ashould(?:n't|n’t| not)\b/i.freeze
|
|
8
8
|
SHOULDNT_BE_PREFIX = /#{SHOULDNT_PREFIX} be\b/i.freeze
|
|
9
9
|
WILL_NOT_PREFIX = /\Awill not\b/i.freeze
|
|
10
|
-
WONT_PREFIX = /\
|
|
10
|
+
WONT_PREFIX = /\Awo(?:n't|n’t)\b/i.freeze
|
|
11
11
|
ES_SUFFIX_PATTERN = /(?:o|s|x|ch|sh|z)\z/i.freeze
|
|
12
12
|
IES_SUFFIX_PATTERN = /[^aeou]y\z/i.freeze
|
|
13
13
|
|
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: 3.0.
|
|
4
|
+
version: 3.0.3
|
|
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: 2024-
|
|
13
|
+
date: 2024-07-12 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rubocop
|
|
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
207
207
|
- !ruby/object:Gem::Version
|
|
208
208
|
version: '0'
|
|
209
209
|
requirements: []
|
|
210
|
-
rubygems_version: 3.5.
|
|
210
|
+
rubygems_version: 3.5.11
|
|
211
211
|
signing_key:
|
|
212
212
|
specification_version: 4
|
|
213
213
|
summary: Code style checking for RSpec files
|