Sha256: da1ebd0ef205f517934fa4c98357f2c8f4c54e6e5f04b570d226db540590bcd2

Contents?: true

Size: 703 Bytes

Versions: 11

Compression:

Stored size: 703 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe RuboCop::Cop::Style::Proc do
  subject(:cop) { described_class.new }

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

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

  it 'accepts the Proc.new call outside of block' do
    inspect_source(cop, ['p = Proc.new'])
    expect(cop.offenses).to be_empty
  end

  it 'auto-corrects Proc.new to proc' do
    corrected = autocorrect_source(cop, ['Proc.new { test }'])
    expect(corrected).to eq 'proc { test }'
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/style/proc_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/style/proc_spec.rb
rubocop-0.28.0 spec/rubocop/cop/style/proc_spec.rb
rubocop-0.27.1 spec/rubocop/cop/style/proc_spec.rb
rubocop-0.27.0 spec/rubocop/cop/style/proc_spec.rb
rubocop-0.26.1 spec/rubocop/cop/style/proc_spec.rb
rubocop-0.26.0 spec/rubocop/cop/style/proc_spec.rb
rubocop-0.25.0 spec/rubocop/cop/style/proc_spec.rb
rubocop-0.24.1 spec/rubocop/cop/style/proc_spec.rb
rubocop-0.24.0 spec/rubocop/cop/style/proc_spec.rb
rubocop-0.23.0 spec/rubocop/cop/style/proc_spec.rb