Sha256: e67857dbffb190006f38020bfc0895d5b01363798b669c5b0c67e56389c69f9e

Contents?: true

Size: 1.46 KB

Versions: 15

Compression:

Stored size: 1.46 KB

Contents

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

describe Simplabs::Excellent::Checks::ClassLineCountCheck do

  before do
    @excellent = Simplabs::Excellent::Runner.new(Simplabs::Excellent::Checks::ClassLineCountCheck.new({ :threshold => 3 }))
  end

  describe '#evaluate' do

    it 'should accept classes with less lines than the threshold' do
      code = <<-END
        class OneLineClass; end
      END
      @excellent.check_code(code)

      @excellent.warnings.should be_empty
    end

    it 'should accept classes with the same number of lines as the threshold' do
      code = <<-END
        class ThreeLineClass
          @foo = 1
        end
      END
      @excellent.check_code(code)

      @excellent.warnings.should be_empty
    end

    it 'should not count blank lines' do
      code = <<-END
        class ThreeLineClass

          @foo = 1

        end
      END
      @excellent.check_code(code)

      @excellent.warnings.should be_empty
    end

    it 'should reject classes with more lines than the threshold' do
      code = <<-END
        class FourLineClass
          @foo = 1
          @bar = 2
        end
      END
      @excellent.check_code(code)
      warnings = @excellent.warnings

      warnings.should_not be_empty
      warnings[0].info.should        == { :class => 'FourLineClass', :count => 4 }
      warnings[0].line_number.should == 1
      warnings[0].message.should     == 'FourLineClass has 4 lines.'
    end

  end

end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
simplabs-excellent-1.2.2 spec/checks/class_line_count_check_spec.rb
simplabs-excellent-1.3.0 spec/checks/class_line_count_check_spec.rb
simplabs-excellent-1.3.1 spec/checks/class_line_count_check_spec.rb
simplabs-excellent-1.4.0 spec/checks/class_line_count_check_spec.rb
simplabs-excellent-1.4.1 spec/checks/class_line_count_check_spec.rb
simplabs-excellent-1.4.2 spec/checks/class_line_count_check_spec.rb
simplabs-excellent-1.5.0 spec/checks/class_line_count_check_spec.rb
simplabs-excellent-1.5.1 spec/checks/class_line_count_check_spec.rb
simplabs-excellent-1.5.2 spec/checks/class_line_count_check_spec.rb
simplabs-excellent-1.5.3 spec/checks/class_line_count_check_spec.rb
excellent-1.7.2 spec/checks/class_line_count_check_spec.rb
excellent-1.7.1 spec/checks/class_line_count_check_spec.rb
excellent-1.7.0 spec/checks/class_line_count_check_spec.rb
excellent-1.6.0 spec/checks/class_line_count_check_spec.rb
excellent-1.5.4 spec/checks/class_line_count_check_spec.rb