Skip to content

Commit

Permalink
Support numblock on RSpec/RedundantAround
Browse files Browse the repository at this point in the history
  • Loading branch information
r7kamura committed Dec 19, 2022
1 parent ca82246 commit 9199fc4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/redundant_around.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def on_send(node)
def_node_matcher :match_redundant_around_hook_block?, <<~PATTERN
(block
(send _ :around ...)
(args _)
(args _?)
(send _ :run)
)
PATTERN
Expand Down
15 changes: 15 additions & 0 deletions spec/rubocop/cop/rspec/redundant_around_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@
end
end

context 'with redundant numblock `around`' do
it 'registers offense' do
expect_offense(<<~RUBY)
around do
^^^^^^^^^ Remove redundant `around` hook.
_1.run
end
RUBY

expect_correction(<<~RUBY)
RUBY
end
end

context 'with redundant `config.around' do
it 'registers offense' do
expect_offense(<<~RUBY)
Expand Down

0 comments on commit 9199fc4

Please sign in to comment.