Sha256: bdc397c142db878a758ec34423cd1c055d4677d09de37d9a2cf65556b25fe1c6

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Lint
      describe Eval do
        subject(: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.messages)
            .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.messages)
            .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

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.13.1 spec/rubocop/cop/lint/eval_spec.rb
rubocop-0.13.0 spec/rubocop/cop/lint/eval_spec.rb