Sha256: 09aceb66bda71ab801b99902e8001868a40902c664dd4e9141f582574d1dd39a

Contents?: true

Size: 997 Bytes

Versions: 5

Compression:

Stored size: 997 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

      it 'registers an offence for empty rescue block' do
        inspect_source(he,
                       'file.rb',
                       ['begin',
                        '  something',
                        'rescue',
                        '  #do nothing',
                        'end'])
        expect(he.offences.size).to eq(1)
        expect(he.offences.map(&:message))
          .to eq([HandleExceptions::ERROR_MESSAGE])
      end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-0.7.2 spec/rubocop/cops/handle_exceptions_spec.rb
rubocop-0.7.1 spec/rubocop/cops/handle_exceptions_spec.rb
rubocop-0.7.0 spec/rubocop/cops/handle_exceptions_spec.rb
rubocop-0.6.1 spec/rubocop/cops/handle_exceptions_spec.rb
rubocop-0.6.0 spec/rubocop/cops/handle_exceptions_spec.rb