Sha256: 2d81840db4a09e889e8624508bf218ef8c3157f3b97a623c2fae55edce526291

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 KB

Contents

require 'test_helper'

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

      describe '#check' do
        describe 'when the class does not use else clauses' do
          it 'returns a SuccessAnalysis' do
            klass = """
            class Foo
              def initialize
                if 3
                  8
                end
                unless 9
                  3
                end
              end
            end""".to_ast

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

        describe 'when the class uses else clauses' do
          it 'returns a FailureAnalysis' do
            klass = """
            class Foo
              def initialize
                if 3
                  8
                else
                  9
                end
              end
            end""".to_ast

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pelusa-0.2.3 test/pelusa/lint/else_clauses_test.rb
pelusa-0.2.2 test/pelusa/lint/else_clauses_test.rb
pelusa-0.2.1 test/pelusa/lint/else_clauses_test.rb
pelusa-0.2.0 test/pelusa/lint/else_clauses_test.rb
pelusa-0.1.1 test/pelusa/lint/else_clauses_test.rb
pelusa-0.1.0 test/pelusa/lint/else_clauses_test.rb
pelusa-0.0.2 test/pelusa/lint/else_clauses_test.rb
pelusa-0.0.1 test/pelusa/lint/else_clauses_test.rb