Sha256: d8a188bd9eb229db1ec91583e54632c0ac451be76acbcbf9e5272cc6f8c23416

Contents?: true

Size: 859 Bytes

Versions: 7

Compression:

Stored size: 859 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Lint
      describe EndInMethod do
        let(: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

7 entries across 7 versions & 2 rubygems

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