Sha256: f3cbd650f24ae3a3ccbe41b1aff2e611018332120d317c6746e102027d660e39

Contents?: true

Size: 617 Bytes

Versions: 3

Compression:

Stored size: 617 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-0.8.3 spec/rubocop/cops/proc_spec.rb
rubocop-0.8.2 spec/rubocop/cops/proc_spec.rb
rubocop-0.8.1 spec/rubocop/cops/proc_spec.rb