Sha256: eabea2d0b1f15b94d93737fbc294a3f26a164c855b4e3cf7dc31f57137b93ee7

Contents?: true

Size: 807 Bytes

Versions: 6

Compression:

Stored size: 807 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Lint::HandleExceptions do
  subject(:cop) { described_class.new }

  it 'registers an offense for empty rescue block' do
    inspect_source(cop,
                   ['begin',
                    '  something',
                    'rescue',
                    '  #do nothing',
                    'end'])
    expect(cop.offenses.size).to eq(1)
    expect(cop.messages)
      .to eq(['Do not suppress exceptions.'])
  end

  it 'does not register an offense for rescue with body' do
    inspect_source(cop,
                   ['begin',
                    '  something',
                    '  return',
                    'rescue',
                    '  file.close',
                    'end'])
    expect(cop.offenses).to be_empty
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubocop-0.22.0 spec/rubocop/cop/lint/handle_exceptions_spec.rb
rubocop-0.21.0 spec/rubocop/cop/lint/handle_exceptions_spec.rb
rubocop-0.20.1 spec/rubocop/cop/lint/handle_exceptions_spec.rb
rubocop-0.20.0 spec/rubocop/cop/lint/handle_exceptions_spec.rb
rubocop-0.19.1 spec/rubocop/cop/lint/handle_exceptions_spec.rb
rubocop-0.19.0 spec/rubocop/cop/lint/handle_exceptions_spec.rb