Skip to content

Commit 5959ad6

Browse files
authored
Merge pull request #1962 from G-Rath/add-spec
test: showcase `RSpec/UnspecifiedException` block/chain confusion is fixed
2 parents 79e0bf7 + 1f48c7b commit 5959ad6

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Master (Unreleased)
44

55
- Fix false-positive for `RSpec/UnspecifiedException` when a method is literally named `raise_exception`. ([@aarestad])
6+
- Fix false-positive for `RSpec/UnspecifiedException` when `not_to raise_error` is used within a block. ([@aarestad], [@G-Rath])
67

78
## 3.0.5 (2024-09-07)
89

spec/rubocop/cop/rspec/unspecified_exception_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ def raise_exception
223223
RUBY
224224
end
225225

226+
it 'does not confuse blocks with chains' do
227+
expect_no_offenses(<<~RUBY)
228+
expect do
229+
expect { foo }.not_to raise_error
230+
end.to change(Foo, :count).by(3)
231+
RUBY
232+
end
233+
226234
it 'allows a subject function to be named raise_exception' do
227235
expect_no_offenses(<<~RUBY)
228236
def raise_error

0 commit comments

Comments
 (0)