Sha256: 88a51a8c639ebcce414bbc55b6ba5441119fb9f1153964fe300cb2cadf3a99c8

Contents?: true

Size: 919 Bytes

Versions: 4

Compression:

Stored size: 919 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,
                       ['begin',
                        '  something',
                        'rescue',
                        '  #do nothing',
                        'end'])
        expect(he.offences.size).to eq(1)
        expect(he.offences.map(&:message))
          .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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.8.3 spec/rubocop/cops/handle_exceptions_spec.rb
rubocop-0.8.2 spec/rubocop/cops/handle_exceptions_spec.rb
rubocop-0.8.1 spec/rubocop/cops/handle_exceptions_spec.rb
rubocop-0.8.0 spec/rubocop/cops/handle_exceptions_spec.rb