Skip to content

Commit eb61748

Browse files
committed
Revert an change that would conceal unintentional RSpec syntax
Specifically: expect { ... }.to change { ... }.by(...) and change { ... }.by(...) Here the usage of `and` is incorrect, as RSpec does not (and can't reasonably) support it. Compound should use the `and` method, not the operator, or the `&`. Same for `.or` and `|`.
1 parent 954a45f commit eb61748

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Change `RSpec/ContextWording` cop to always report an offense when both `Prefixes` and `AllowedPatterns` are empty. ([@ydah])
66
- Fix an error for `RSpec/ChangeByZero` when `change (...) .by (0)` and `change (...)`, concatenated with `and` and `or`. ([@ydah])
7+
- Revert an change that would conceal unintentional RSpec syntax. ([@pirj])
78

89
## 3.1.0 (2024-10-01)
910

lib/rubocop/cop/rspec/change_by_zero.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,8 @@ def register_offense(node, change_node)
118118
# rubocop:enable Metrics/MethodLength
119119

120120
def compound_expectations?(node)
121-
if node.parent.send_type?
121+
node.parent.send_type? &&
122122
%i[and or & |].include?(node.parent.method_name)
123-
else
124-
node.parent.and_type? || node.parent.or_type?
125-
end
126123
end
127124

128125
def message(change_node)

0 commit comments

Comments
 (0)