Sha256: 40fcbd24f4bf79f971d7b9b09041c9f51e0e2cfc6790c22025ccd1f1353ba724

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

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

describe Simplabs::Excellent::Checks::ClassNameCheck do

  before(:each) do
    @excellent = Simplabs::Excellent::Runner.new(Simplabs::Excellent::Checks::ClassNameCheck.new)
  end

  describe '#evaluate' do

    it 'should accept camel case class names starting in capitals' do
      content = <<-END
        class GoodClassName; end
      END
      @excellent.check_content(content)

      @excellent.warnings.should be_empty
    end

    it 'should be able to parse scoped class names' do
      content = <<-END
        class Outer::Inner::GoodClassName 
          def method
          end
        end
      END
      @excellent.check_content(content)

      @excellent.warnings.should be_empty
    end

    it 'should reject class names with underscores' do
      content = <<-END
        class Bad_ClassName
        end
      END
      @excellent.check_content(content)
      warnings = @excellent.warnings

      warnings.should_not be_empty
      warnings[0].info.should        == { :class => 'Bad_ClassName' }
      warnings[0].line_number.should == 1
      warnings[0].message.should     == 'Bad class name Bad_ClassName.'
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simplabs-excellent-1.2.1 spec/checks/class_name_check_spec.rb