Sha256: 50b837cb4559b5dc4f78b90ce939fa2b0940c633183ed1cbf5e88a54c369f6cd

Contents?: true

Size: 980 Bytes

Versions: 2

Compression:

Stored size: 980 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Lint
      describe HandleExceptions do
        subject(:he) { HandleExceptions.new }

        it 'registers an offence for empty rescue block' do
          inspect_source(he,
                         ['begin',
                          '  something',
                          'rescue',
                          '  #do nothing',
                          'end'])
          expect(he.offences.size).to eq(1)
          expect(he.messages)
            .to eq([HandleExceptions::MSG])
        end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.13.1 spec/rubocop/cop/lint/handle_exceptions_spec.rb
rubocop-0.13.0 spec/rubocop/cop/lint/handle_exceptions_spec.rb