Sha256: 063af2ee1669b56862c84608bb1a2c37294f7bb575f4878f1c5bde25fe90f497

Contents?: true

Size: 1019 Bytes

Versions: 2

Compression:

Stored size: 1019 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Lint
      describe EnsureReturn do
        let(:er) { EnsureReturn.new }

        it 'registers an offence for return in ensure' do
          inspect_source(er,
                         ['begin',
                          '  something',
                          'ensure',
                          '  file.close',
                          '  return',
                          'end'])
          expect(er.offences.size).to eq(1)
          expect(er.offences.map(&:message))
            .to eq([EnsureReturn::MSG])
        end

        it 'does not register an offence for return outside ensure' do
          inspect_source(er,
                         ['begin',
                          '  something',
                          '  return',
                          'ensure',
                          '  file.close',
                          'end'])
          expect(er.offences).to be_empty
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
sabat-rubocop-0.9.0 spec/rubocop/cops/lint/ensure_return_spec.rb
rubocop-0.9.0 spec/rubocop/cops/lint/ensure_return_spec.rb