Sha256: 2c7a8021819ab0e50adf82f50d7e1e93886915b861fba58361e223fb78f46aa8

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

require 'test_helper'

module Pelusa
  describe Analyzer do
    describe '#analyze' do
      describe 'with a multi-expression AST' do
        before do
          @ast = """
            class Foo
              def bar
                123
              end
            end

            class Bar
              def baz
                321
              end
            end

            module Baz
              def bar
                2.7
              end
            end
          """.to_ast

          lints = stub
          @analyzer = Analyzer.new([Lint::LineRestriction], RubyReporter, "foo.rb")
        end

        it 'analyzes an ast and returns a report' do
          result = @analyzer.analyze(@ast).report
          result[:filename].must_equal "foo.rb"
          result[:Foo]["Is below 50 lines"][:status].must_equal "successful"
          result[:Bar]["Is below 50 lines"][:status].must_equal "successful"
          result[:Baz]["Is below 50 lines"][:status].must_equal "successful"
        end
      end

      describe 'with a single-expression AST' do
        before do
          @ast = """
            class Foo
              def bar
                123
              end
            end
          """.to_ast

          lints = stub
          @analyzer = Analyzer.new([Lint::LineRestriction], RubyReporter, "foo.rb")
        end

        it 'analyzes an ast and returns a report' do
          result = @analyzer.analyze(@ast).report
          result[:filename].must_equal "foo.rb"
          result[:Foo]["Is below 50 lines"][:status].must_equal "successful"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pelusa-0.2.3 test/pelusa/analyzer_test.rb