Skip to content

Commit

Permalink
Lint/SuppressedException: Explicit AllowComments config in spec
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed May 21, 2020
1 parent 36d3e30 commit 2e8f013
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions spec/rubocop/cop/lint/suppressed_exception_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 2e8f013

Please sign in to comment.