Sha256: 790f56cf791b26f06568d16e32c9ac1805a92a3cd01d41083133c1a4e2510f90

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 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 = klass_str.to_ast
            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 = klass_str.to_ast
            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 = klass_str.to_ast
            analysis = @lint.check(klass)
            analysis.successful?.must_equal true
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pelusa-0.2.3 test/pelusa/lint/eval_usage_test.rb
pelusa-0.2.2 test/pelusa/lint/eval_usage_test.rb
pelusa-0.2.1 test/pelusa/lint/eval_usage_test.rb