rubocop-rspec 3.1.0 → 3.2.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47c427b063cba22b4601d8244b18db288081f95889e287be82473e9148748c2e
|
4
|
+
data.tar.gz: 9d9543614cb00ee6cf4c94c750ce2368a4e34dae73f1a778e3fc9a7470698526
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04fb1fe03b1fb818c7ee43d937fbb394e93a91e70c0cc00c06d259c53210ebb6b5243b584342838de566e99d0263d60b975113362b3a6306acf31f46ea2ed0ff
|
7
|
+
data.tar.gz: 66daeeaff0d894825dfcf0dc836b0fc614490b358b508ddaacc98652c37f0dc6e9c29e38222493e21a662f848a20efce503fe25a349b7a16fcc3693b9ecac4a1
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## Master (Unreleased)
|
4
4
|
|
5
|
+
## 3.2.0 (2024-10-26)
|
6
|
+
|
7
|
+
- Fix `RSpec/VoidExpect` to only operate inside an example block. ([@corsonknowles])
|
8
|
+
- Change `RSpec/ContextWording` cop to always report an offense when both `Prefixes` and `AllowedPatterns` are empty. ([@ydah])
|
9
|
+
- Add support for `and` and `or` compound matchers to `RSpec/ChangeByZero` cop. ([@ydah])
|
10
|
+
|
5
11
|
## 3.1.0 (2024-10-01)
|
6
12
|
|
7
13
|
- Add `RSpec/StringAsInstanceDoubleConstant` to check for and correct strings used as instance_doubles. ([@corsonknowles])
|
data/config/default.yml
CHANGED
@@ -403,6 +403,7 @@ RSpec/ExampleWithoutDescription:
|
|
403
403
|
- single_line_only
|
404
404
|
- disallow
|
405
405
|
VersionAdded: '1.22'
|
406
|
+
StyleGuide: https://rspec.rubystyle.guide/#it-and-specify
|
406
407
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleWithoutDescription
|
407
408
|
|
408
409
|
RSpec/ExampleWording:
|
@@ -118,7 +118,8 @@ module RuboCop
|
|
118
118
|
# rubocop:enable Metrics/MethodLength
|
119
119
|
|
120
120
|
def compound_expectations?(node)
|
121
|
-
|
121
|
+
node.parent.send_type? &&
|
122
|
+
%i[and or & |].include?(node.parent.method_name)
|
122
123
|
end
|
123
124
|
|
124
125
|
def message(change_node)
|
@@ -12,6 +12,9 @@ module RuboCop
|
|
12
12
|
#
|
13
13
|
# @see http://www.betterspecs.org/#contexts
|
14
14
|
#
|
15
|
+
# If both `Prefixes` and `AllowedPatterns` are empty, this cop will always
|
16
|
+
# report an offense. So you need to set at least one of them.
|
17
|
+
#
|
15
18
|
# @example `Prefixes` configuration
|
16
19
|
# # .rubocop.yml
|
17
20
|
# # RSpec/ContextWording:
|
@@ -58,7 +61,9 @@ module RuboCop
|
|
58
61
|
class ContextWording < Base
|
59
62
|
include AllowedPattern
|
60
63
|
|
61
|
-
|
64
|
+
MSG_MATCH = 'Context description should match %<patterns>s.'
|
65
|
+
MSG_ALWAYS = 'Current settings will always report an offense. Please ' \
|
66
|
+
'add allowed words to `Prefixes` or `AllowedPatterns`.'
|
62
67
|
|
63
68
|
# @!method context_wording(node)
|
64
69
|
def_node_matcher :context_wording, <<~PATTERN
|
@@ -67,8 +72,7 @@ module RuboCop
|
|
67
72
|
|
68
73
|
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
|
69
74
|
context_wording(node) do |context|
|
70
|
-
|
71
|
-
message = format(MSG, patterns: expect_patterns)
|
75
|
+
unless matches_allowed_pattern?(description(context))
|
72
76
|
add_offense(context, message: message)
|
73
77
|
end
|
74
78
|
end
|
@@ -84,12 +88,6 @@ module RuboCop
|
|
84
88
|
@prefix_regexes ||= prefixes.map { |pre| /^#{Regexp.escape(pre)}\b/ }
|
85
89
|
end
|
86
90
|
|
87
|
-
def bad_pattern?(node)
|
88
|
-
return false if allowed_patterns.empty?
|
89
|
-
|
90
|
-
!matches_allowed_pattern?(description(node))
|
91
|
-
end
|
92
|
-
|
93
91
|
def description(context)
|
94
92
|
if context.xstr_type?
|
95
93
|
context.value.value
|
@@ -98,6 +96,14 @@ module RuboCop
|
|
98
96
|
end
|
99
97
|
end
|
100
98
|
|
99
|
+
def message
|
100
|
+
if allowed_patterns.empty?
|
101
|
+
MSG_ALWAYS
|
102
|
+
else
|
103
|
+
format(MSG_MATCH, patterns: expect_patterns)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
101
107
|
def expect_patterns
|
102
108
|
inspected = allowed_patterns.map do |pattern|
|
103
109
|
pattern.inspect.gsub(/\A"|"\z/, '/')
|
@@ -29,12 +29,14 @@ module RuboCop
|
|
29
29
|
|
30
30
|
def on_send(node)
|
31
31
|
return unless expect?(node)
|
32
|
+
return unless inside_example?(node)
|
32
33
|
|
33
34
|
check_expect(node)
|
34
35
|
end
|
35
36
|
|
36
37
|
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
|
37
38
|
return unless expect_block?(node)
|
39
|
+
return unless inside_example?(node)
|
38
40
|
|
39
41
|
check_expect(node)
|
40
42
|
end
|
@@ -49,11 +51,14 @@ module RuboCop
|
|
49
51
|
|
50
52
|
def void?(expect)
|
51
53
|
parent = expect.parent
|
52
|
-
return true unless parent
|
53
54
|
return true if parent.begin_type?
|
54
55
|
|
55
56
|
parent.block_type? && parent.body == expect
|
56
57
|
end
|
58
|
+
|
59
|
+
def inside_example?(node)
|
60
|
+
node.each_ancestor(:block).any? { |ancestor| example?(ancestor) }
|
61
|
+
end
|
57
62
|
end
|
58
63
|
end
|
59
64
|
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: 3.
|
4
|
+
version: 3.2.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: 2024-10-
|
13
|
+
date: 2024-10-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|