Sha256: 8f3d02e934289400e84a180602b3c0b2aa47f9f48e566abb9b17a95d9acfbde9

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require 'test_helper'

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

      describe '#check' do
        describe 'when the class contains no short identifiers' do
          it 'returns a SuccessAnalysis' do
            klass = """
            class Foo
              def initialize
                foo = 3
              end
            end""".to_ast

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

        describe 'when the class contains short identifier from reserved list' do
          it 'returns a SuccessAnalysis' do
            klass = """
            class Foo
              def initialize
                id = 2
                pp id
              end
            end""".to_ast

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

        describe 'when the class contains a short identifier' do
          it 'returns a FailureAnalysis' do
            klass = """
            class Foo
              def initialize
                x = 2
              end
            end""".to_ast

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pelusa-0.2.3 test/pelusa/lint/short_identifiers_test.rb
pelusa-0.2.2 test/pelusa/lint/short_identifiers_test.rb