Sha256: 08d7d42199c85602db9384906ff30a60d66e3d990f218c1986fec45b669403be

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

# encoding: utf-8
require 'test_helper'

module Pelusa
  module Lint
    describe EvalUsage do
      before { @lint = EvalUsage.new }

      describe '#check' do
        describe 'when class does not use eval statement' do
          it 'return successful analysis' do
            klass_str = <<RUBY
class WithoutEval
  def initialize
    @good = true
  end
end
RUBY
            klass = Pelusa.to_ast klass_str
            analysis = @lint.check(klass)
            analysis.successful?.must_equal true
          end
        end

        describe 'when class use eval statement' do
          it 'return failed analysis' do
            klass_str = <<RUBY
class WithEval
  def initialize
    eval "@good = false"
  end
end
RUBY
            klass = Pelusa.to_ast klass_str
            analysis = @lint.check(klass)
            analysis.failed?.must_equal true
          end
        end

        describe 'when class define method named eval' do
          it 'return successful analysis' do
            klass_str = <<RUBY
class WithEvalUse
  def initialize
    @other_obj = Object.new
    @other_obj.eval "boom"
  end
end
RUBY
            klass = Pelusa.to_ast klass_str
            analysis = @lint.check(klass)
            analysis.successful?.must_equal true
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pelusa-0.2.4 test/pelusa/lint/eval_usage_test.rb