From 9199fc4d3bf5f685fa5f31cc549aa6d9085d8cea Mon Sep 17 00:00:00 2001 From: r7kamura Date: Mon, 19 Dec 2022 11:24:59 +0900 Subject: [PATCH] Support numblock on `RSpec/RedundantAround` --- lib/rubocop/cop/rspec/redundant_around.rb | 2 +- spec/rubocop/cop/rspec/redundant_around_spec.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/rubocop/cop/rspec/redundant_around.rb b/lib/rubocop/cop/rspec/redundant_around.rb index f49811646c..3429fafcb0 100644 --- a/lib/rubocop/cop/rspec/redundant_around.rb +++ b/lib/rubocop/cop/rspec/redundant_around.rb @@ -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 diff --git a/spec/rubocop/cop/rspec/redundant_around_spec.rb b/spec/rubocop/cop/rspec/redundant_around_spec.rb index bc85485adf..0150aafa24 100644 --- a/spec/rubocop/cop/rspec/redundant_around_spec.rb +++ b/spec/rubocop/cop/rspec/redundant_around_spec.rb @@ -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)