Sha256: 4523552eb7b925a0d4050ee7c410075d51899052928e87de252a4e5fdeef7d79

Contents?: true

Size: 867 Bytes

Versions: 4

Compression:

Stored size: 867 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Lint::Eval do
  subject(:cop) { described_class.new }

  it 'registers an offense for eval as function' do
    inspect_source(cop,
                   ['eval(something)'])
    expect(cop.offenses.size).to eq(1)
    expect(cop.highlights) .to eq(['eval'])
  end

  it 'registers an offense for eval as command' do
    inspect_source(cop,
                   ['eval something'])
    expect(cop.offenses.size).to eq(1)
    expect(cop.highlights) .to eq(['eval'])
  end

  it 'does not register an offense for eval as variable' do
    inspect_source(cop,
                   ['eval = something'])
    expect(cop.offenses).to be_empty
  end

  it 'does not register an offense for eval as method' do
    inspect_source(cop,
                   ['something.eval'])
    expect(cop.offenses).to be_empty
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.22.0 spec/rubocop/cop/lint/eval_spec.rb
rubocop-0.21.0 spec/rubocop/cop/lint/eval_spec.rb
rubocop-0.20.1 spec/rubocop/cop/lint/eval_spec.rb
rubocop-0.20.0 spec/rubocop/cop/lint/eval_spec.rb