Sha256: fea1f2426c904792e04707d3bef2b4df5beb92ea084ffd008a1c6bcbca721f57

Contents?: true

Size: 676 Bytes

Versions: 2

Compression:

Stored size: 676 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Style
      describe Proc do
        subject(: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

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.13.1 spec/rubocop/cop/style/proc_spec.rb
rubocop-0.13.0 spec/rubocop/cop/style/proc_spec.rb