Sha256: 1822f506cfb87bb913712540371207e896d2ea9dfce18d04a03412d481c4eee0

Contents?: true

Size: 982 Bytes

Versions: 4

Compression:

Stored size: 982 Bytes

Contents

require 'test_helper'

module Pelusa
  module Lint
    describe DemeterLaw do
      before do
        @lint = DemeterLaw.new
      end

      describe '#check' do
        describe 'when the class respects Demeter law' do
          it 'returns a SuccessAnalysis' do
            klass = """
            class Foo
              def initialize
                foo = 'hey'.upcase
                foo.downcase
              end
            end""".to_ast

            analysis = @lint.check(klass)
            analysis.successful?.must_equal true
          end
        end

        describe 'when the class does not respect Demeter law' do
          it 'returns a FailureAnalysis' do
            klass = """
            class Foo
              def initialize
                foo = 'hey'.upcase.downcase
              end
            end""".to_ast

            analysis = @lint.check(klass)
            analysis.failed?.must_equal true
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pelusa-0.1.1 test/pelusa/lint/demeter_law_test.rb
pelusa-0.1.0 test/pelusa/lint/demeter_law_test.rb
pelusa-0.0.2 test/pelusa/lint/demeter_law_test.rb
pelusa-0.0.1 test/pelusa/lint/demeter_law_test.rb