Sha256: 62eaaa8089d6810d325a936d7c869559741a05b623bd4fcb5ed941ba42905ab3

Contents?: true

Size: 991 Bytes

Versions: 7

Compression:

Stored size: 991 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Lint
      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
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
rubocop-0.12.0 spec/rubocop/cop/lint/handle_exceptions_spec.rb
rubocop-0.11.1 spec/rubocop/cop/lint/handle_exceptions_spec.rb
rubocop-0.11.0 spec/rubocop/cops/lint/handle_exceptions_spec.rb
rubocop-0.10.0 spec/rubocop/cops/lint/handle_exceptions_spec.rb
rubocop-0.9.1 spec/rubocop/cops/lint/handle_exceptions_spec.rb
sabat-rubocop-0.9.0 spec/rubocop/cops/lint/handle_exceptions_spec.rb
rubocop-0.9.0 spec/rubocop/cops/lint/handle_exceptions_spec.rb