Sha256: 0ffa5e24be522ed169ad6dbce1ca78eec706d650da57faeaea09cdae0a36c2dd

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

require 'test_helper'

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

      describe '#check' do
        describe 'when the class contains only method definitions with a small number of arguments' do
          it 'returns a SuccessAnalysis' do
            klass = """
            class Foo
              def bar(dog)
                return dog
              end
              def baz(dog, cat)
                return dog + cat
              end
              def bam(dog, cat, fish)
                return dog + cat + fish
              end
            end""".to_ast

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

        describe 'when the class contains a method definition with many arguments' do
          it 'returns a FailureAnalysis' do
            klass = """
            class Foo
              def bar(dog, cat, fish, lobster)
                x = 2
              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/many_arguments_test.rb
pelusa-0.2.2 test/pelusa/lint/many_arguments_test.rb
pelusa-0.2.1 test/pelusa/lint/many_arguments_test.rb
pelusa-0.2.0 test/pelusa/lint/many_arguments_test.rb
pelusa-0.1.1 test/pelusa/lint/many_arguments_test.rb
pelusa-0.1.0 test/pelusa/lint/many_arguments_test.rb