diff --git a/spec/rubocop/cop/lint/suppressed_exception_spec.rb b/spec/rubocop/cop/lint/suppressed_exception_spec.rb index 9e6c3d97f67..e528551526a 100644 --- a/spec/rubocop/cop/lint/suppressed_exception_spec.rb +++ b/spec/rubocop/cop/lint/suppressed_exception_spec.rb @@ -3,29 +3,33 @@ RSpec.describe RuboCop::Cop::Lint::SuppressedException, :config do subject(:cop) { described_class.new(config) } - it 'registers an offense for empty rescue block' do - expect_offense(<<~RUBY) - begin - something - rescue - ^^^^^^ Do not suppress exceptions. - #do nothing - end - RUBY - end + context 'with AllowComments set to false' do + let(:cop_config) { { 'AllowComments' => false } } + + it 'registers an offense for empty rescue block' do + expect_offense(<<~RUBY) + begin + something + rescue + ^^^^^^ Do not suppress exceptions. + #do nothing + end + RUBY + end - it 'does not register an offense for rescue with body' do - expect_no_offenses(<<~RUBY) - begin - something - return - rescue - file.close - end - RUBY + it 'does not register an offense for rescue with body' do + expect_no_offenses(<<~RUBY) + begin + something + return + rescue + file.close + end + RUBY + end end - context 'AllowComments' do + context 'with AllowComments set to true' do let(:cop_config) { { 'AllowComments' => true } } it 'does not register an offense for empty rescue with comment' do