Sha256: 0a2d67a2aeb753e0fbde4c77662062c25489563663c6c058622b93123d8d76be

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

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

describe Roodi::Checks::ClassLineCountCheck do

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

  describe '#evaluate' do

    it 'should accept classes with less lines than the threshold' do
      content = <<-END
        class ZeroLineClass; end
      END
      @roodi.check_content(content)

      @roodi.errors.should be_empty
    end

    it 'should accept classes with the same number of lines as the threshold' do
      content = <<-END
        Class OneLineClass
          @foo = 1
        end
      END
      @roodi.check_content(content)

      @roodi.errors.should be_empty
    end

    it 'should reject classes with more lines than the threshold' do
      content = <<-END
        class TwoLineClass
          @foo = 1
          @bar = 2
        end
      END
      @roodi.check_content(content)
      errors = @roodi.errors

      errors.should_not be_empty
      errors[0].info.should        == { :class => :TwoLineClass, :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/class_line_count_check_spec.rb
marcoow-roodi-1.3.4 spec/roodi/checks/class_line_count_check_spec.rb
marcoow-roodi-1.3.5 spec/roodi/checks/class_line_count_check_spec.rb