Sha256: a7d00be3ab199a513ad91d7b605cb0d205cac37926fb9477496e646cde5d576c

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 KB

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Lint
      describe Eval do
        let(:a) { Eval.new }

        it 'registers an offence for eval as function' do
          inspect_source(a,
                         ['eval(something)'])
          expect(a.offences.size).to eq(1)
          expect(a.offences.map(&:message))
            .to eq([Eval::MSG])
        end

        it 'registers an offence for eval as command' do
          inspect_source(a,
                         ['eval something'])
          expect(a.offences.size).to eq(1)
          expect(a.offences.map(&:message))
            .to eq([Eval::MSG])
        end

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

        it 'does not register an offence for eval as method' do
          inspect_source(a,
                         ['something.eval'])
          expect(a.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/lint/eval_spec.rb
rubocop-0.11.1 spec/rubocop/cop/lint/eval_spec.rb
rubocop-0.11.0 spec/rubocop/cops/lint/eval_spec.rb
rubocop-0.10.0 spec/rubocop/cops/lint/eval_spec.rb
rubocop-0.9.1 spec/rubocop/cops/lint/eval_spec.rb
sabat-rubocop-0.9.0 spec/rubocop/cops/lint/eval_spec.rb
rubocop-0.9.0 spec/rubocop/cops/lint/eval_spec.rb