Skip to content

Commit

Permalink
test: showcase RSpec/UnspecifiedException block/chain confusion is …
Browse files Browse the repository at this point in the history
…fixed
  • Loading branch information
G-Rath committed Sep 26, 2024
1 parent 79e0bf7 commit 1f48c7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Master (Unreleased)

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

## 3.0.5 (2024-09-07)

Expand Down
8 changes: 8 additions & 0 deletions spec/rubocop/cop/rspec/unspecified_exception_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ def raise_exception
RUBY
end

it 'does not confuse blocks with chains' do
expect_no_offenses(<<~RUBY)
expect do
expect { foo }.not_to raise_error
end.to change(Foo, :count).by(3)
RUBY
end

it 'allows a subject function to be named raise_exception' do
expect_no_offenses(<<~RUBY)
def raise_error
Expand Down

0 comments on commit 1f48c7b

Please # to comment.