Skip to content

Commit

Permalink
Fix an error for unrecognized cop or department `RSpecRails/HttpStatu…
Browse files Browse the repository at this point in the history
…s` when also using rubocop-rails

Fix: #8
  • Loading branch information
ydah committed Mar 30, 2024
1 parent ccd821e commit b4f25a4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Fix a `NameError` by Cross-Referencing. ([@ydah])
- Fix an error for `RSpecRails/HttpStatus` when no rack gem is loaded with rubocop-rspec. ([@ydah])
- Fix an error for unrecognized cop or department `RSpecRails/HttpStatus` when also using rubocop-rails. ([@ydah])

## 2.28.1 (2024-03-29)

Expand Down
17 changes: 17 additions & 0 deletions lib/rubocop-rspec_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,20 @@

project_root = File.join(__dir__, '..')
RuboCop::ConfigLoader.inject_defaults!(project_root)

# FIXME: This is a workaround for the following issue:
# https://github.com/rubocop/rubocop-rspec_rails/issues/8
module RuboCop
module Cop
class AmbiguousCopName # rubocop:disable Style/Documentation
prepend(Module.new do
def qualified_cop_name(name, path, warn: true)
return super unless name == 'RSpec/Rails/HttpStatus'

badge = Badge.parse(name)
resolve_badge(badge, qualify_badge(badge).first, path)
end
end)
end
end
end

0 comments on commit b4f25a4

Please sign in to comment.