Sha256: 91755ec48817a65c2f5459c31c9d15c425e974d31b9ecdab6fb53150f6f49895

Contents?: true

Size: 997 Bytes

Versions: 1

Compression:

Stored size: 997 Bytes

Contents

require 'test_helper'

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

      describe '#check' do
        describe 'when the class does not use switch statements' do
          it 'returns a SuccessAnalysis' do
            klass = Pelusa.to_ast """
            class Foo
              def initialize
                return nil
              end
            end"""

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

        describe 'when the class uses case statements' do
          it 'returns a FailureAnalysis' do
            klass = Pelusa.to_ast """
            class Foo
              def initialize
                case foo
                  when bar
                end
              end
            end"""

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pelusa-0.2.4 test/pelusa/lint/case_statements_test.rb