From b7d75ac963abe7a68a3d647d31aa004c8d105030 Mon Sep 17 00:00:00 2001 From: Andrei Eres Date: Tue, 18 May 2021 22:44:00 +0300 Subject: [PATCH] Test extra cases for redundant cop enable directive --- .../lint/redundant_cop_enable_directive_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/rubocop/cop/lint/redundant_cop_enable_directive_spec.rb b/spec/rubocop/cop/lint/redundant_cop_enable_directive_spec.rb index c5f4fa68edf..93d3548a4de 100644 --- a/spec/rubocop/cop/lint/redundant_cop_enable_directive_spec.rb +++ b/spec/rubocop/cop/lint/redundant_cop_enable_directive_spec.rb @@ -325,5 +325,22 @@ # rubocop:enable Layout RUBY end + + it 'registers offense and corrects redundant enabling of department of same cop' do + expect_offense(<<~RUBY) + # rubocop:disable Layout/LineLength + fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo = barrrrrrrrrrrrrrrrrrrrrrrrrr + # rubocop:enable Layout + ^^^^^^ Unnecessary enabling of Layout. + some_code + RUBY + + expect_correction(<<~RUBY) + # rubocop:disable Layout/LineLength + fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo = barrrrrrrrrrrrrrrrrrrrrrrrrr + + some_code + RUBY + end end end