Skip to content

Commit

Permalink
Fix RSpecRails::HttpStatus cop to ignore unexpected objects
Browse files Browse the repository at this point in the history
  • Loading branch information
viralpraxis committed Oct 2, 2024
1 parent 41a3bd4 commit ff3f1aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Master (Unreleased)

- Fix invalid autocorrection for `RSpecRails/HttpStatus` cop when unexpected object is passed. ([@viralpraxis])

## 2.30.0 (2024-06-12)

- Fix an runtime error for rubocop-rspec +3.0. ([@bquorning])
Expand Down Expand Up @@ -81,4 +83,5 @@
[@r7kamura]: https://github.com/r7kamura
[@splattael]: https://github.com/splattael
[@tmaier]: https://github.com/tmaier
[@viralpraxis]: https://github.com/viralpraxis
[@ydah]: https://github.com/ydah
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec_rails/http_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def custom_http_status_code?
# :nodoc:
class SymbolicStyleChecker < StyleCheckerBase
def offensive?
!node.sym_type? && !custom_http_status_code?
!node.sym_type? && !custom_http_status_code? && symbol
end

def prefer
Expand Down
6 changes: 6 additions & 0 deletions spec/rubocop/cop/rspec_rails/http_status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@
RUBY
end
end

it 'registers no offenses when using unexpected object' do
expect_no_offenses(<<~RUBY)
it { is_expected.to have_http_status("some-custom-string") }
RUBY
end
end

context 'when EnforcedStyle is `numeric`' do
Expand Down

0 comments on commit ff3f1aa

Please sign in to comment.