Sha256: 3c109f79345e3fa16731c9aec432b8ab43d3ccea3c4e89e79a638368a2b5f4be

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe Roodi::Checks::MethodLineCountCheck do

  before(:each) do
    @roodi = Roodi::Core::ParseTreeRunner.new(Roodi::Checks::MethodLineCountCheck.new({'line_count' => 1}))
  end

  describe '#evaluate' do

    it 'should accept methods with less lines than the threshold' do
      content = <<-END
        def zero_line_method
        end
      END
      @roodi.check_content(content)

      @roodi.errors.should be_empty
    end

    it 'should accept methods with the same number of lines as the threshold' do
      content = <<-END
        def one_line_method
          1
        end
      END
      @roodi.check_content(content)

      @roodi.errors.should be_empty
    end

    it 'should reject methods with more lines than the threshold' do
      content = <<-END
        def two_line_method
          puts 1
          puts 2
        end
      END
      @roodi.check_content(content)
      errors = @roodi.errors

      errors.should_not be_empty
      errors[0].info.should        == { :method => :two_line_method, :count => 2 }
      errors[0].filename.should    == 'dummy-file.rb'
      errors[0].line_number.should == 1
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
marcoow-roodi-1.3.2 spec/roodi/checks/method_line_count_check_spec.rb
marcoow-roodi-1.3.4 spec/roodi/checks/method_line_count_check_spec.rb
marcoow-roodi-1.3.5 spec/roodi/checks/method_line_count_check_spec.rb