Sha256: 4c37fdb43c677f7a984d3888bb91b15e15aea6dce6eef098b70c8d1b0b230bee

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 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(1))
  end
  
  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].should eql("dummy-file.rb:1 - Method name \"two_line_method\" has 2 lines.  It should have 1 or less.")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
roodi-0.5 spec/checks/method_line_count_check_spec.rb
roodi-1.1.0 spec/checks/method_line_count_check_spec.rb
roodi-1.1.1 spec/checks/method_line_count_check_spec.rb