Sha256: 9e65383565bd75126081b0703ff88b2e74b38cb92b32117b3b5e6eb205141ebc

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

require 'test_helper'

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

            class Bar
              def baz
                321
              end
            end

            module Baz
              def bar
                2.7
              end
            end
          """

          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 = Pelusa.to_ast """
            class Foo
              def bar
                123
              end
            end
          """

          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.4 test/pelusa/analyzer_test.rb