Skip to content

Commit

Permalink
Merge pull request #1962 from G-Rath/add-spec
Browse files Browse the repository at this point in the history
test: showcase `RSpec/UnspecifiedException` block/chain confusion is fixed
  • Loading branch information
bquorning authored Sep 26, 2024
2 parents 79e0bf7 + 1f48c7b commit 5959ad6
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 5959ad6

Please sign in to comment.