Sha256: 6f063bcac92e672afec3a6db0b593f36ee235abdf392d3758f65ac452eb47384

Contents?: true

Size: 983 Bytes

Versions: 6

Compression:

Stored size: 983 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 = """
            class Foo
              def initialize
                return nil
              end
            end""".to_ast

            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 = """
            class Foo
              def initialize
                case foo
                  when bar
                end
              end
            end""".to_ast

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pelusa-0.2.3 test/pelusa/lint/case_statements_test.rb
pelusa-0.2.2 test/pelusa/lint/case_statements_test.rb
pelusa-0.2.1 test/pelusa/lint/case_statements_test.rb
pelusa-0.2.0 test/pelusa/lint/case_statements_test.rb
pelusa-0.1.1 test/pelusa/lint/case_statements_test.rb
pelusa-0.1.0 test/pelusa/lint/case_statements_test.rb