Sha256: 6dc347d44cadb0c8b965cd6eee8cfe2c7ce76024bff0e564123977dc4bc9ea7e

Contents?: true

Size: 863 Bytes

Versions: 2

Compression:

Stored size: 863 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Lint
      describe EndInMethod do
        subject(:cop) { EndInMethod.new }

        it 'reports an offence for def with an END inside' do
          src = ['def test',
                 '  END { something }',
                 'end']
          inspect_source(cop, src)
          expect(cop.offences.size).to eq(1)
        end

        it 'reports an offence for defs with an END inside' do
          src = ['def self.test',
                 '  END { something }',
                 'end']
          inspect_source(cop, src)
          expect(cop.offences.size).to eq(1)
        end

        it 'accepts END outside of def(s)' do
          src = ['END { something }']
          inspect_source(cop, src)
          expect(cop.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/end_in_method_spec.rb
rubocop-0.13.0 spec/rubocop/cop/lint/end_in_method_spec.rb