Sha256: 9d2ae71e3bf8eb8536bfd3219255dbf291584d23b35bc73c0d52368a7144b3df

Contents?: true

Size: 672 Bytes

Versions: 7

Compression:

Stored size: 672 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Style
      describe Proc do
        let(:proc) { Proc.new }

        it 'registers an offence for a Proc.new call' do
          inspect_source(proc, ['f = Proc.new { |x| puts x }'])
          expect(proc.offences.size).to eq(1)
        end

        it 'accepts the proc method' do
          inspect_source(proc, ['f = proc { |x| puts x }'])
          expect(proc.offences).to be_empty
        end

        it 'accepts the Proc.new call outside of block' do
          inspect_source(proc, ['p = Proc.new'])
          expect(proc.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/style/proc_spec.rb
rubocop-0.11.1 spec/rubocop/cop/style/proc_spec.rb
rubocop-0.11.0 spec/rubocop/cops/style/proc_spec.rb
rubocop-0.10.0 spec/rubocop/cops/style/proc_spec.rb
rubocop-0.9.1 spec/rubocop/cops/style/proc_spec.rb
sabat-rubocop-0.9.0 spec/rubocop/cops/style/proc_spec.rb
rubocop-0.9.0 spec/rubocop/cops/style/proc_spec.rb