Sha256: 9a40049af251756da8e3ea41ec53e63df28ec845c3786869bf813ff62c423bdd

Contents?: true

Size: 1.61 KB

Versions: 15

Compression:

Stored size: 1.61 KB

Contents

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

describe Simplabs::Excellent::Checks::ModuleNameCheck do

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

  describe '#evaluate' do

    it 'should accept camel case module names starting in capitals' do
      code = <<-END
        module GoodModuleName 
        end
      END
      @excellent.check_code(code)

      @excellent.warnings.should be_empty
    end

    it 'should accept namespaced modules' do
      code = <<-END
        module Outer::Inner::GoodModuleName 
        end
      END
      @excellent.check_code(code)

      @excellent.warnings.should be_empty
    end

    it 'should reject module names with underscores' do
      code = <<-END
        module Bad_ModuleName 
        end
      END
      @excellent.check_code(code)
      warnings = @excellent.warnings

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

    it 'should correctly report bad names of namespaced modules' do
      code = <<-END
        module Outer::Inner::Bad_ModuleName
        end
      END
      @excellent.check_code(code)
      warnings = @excellent.warnings

      warnings.should_not be_empty
      warnings[0].info.should        == { :module => 'Outer::Inner::Bad_ModuleName' }
      warnings[0].line_number.should == 1
      warnings[0].message.should     == 'Bad module name Outer::Inner::Bad_ModuleName.'
    end

  end

end

Version data entries

15 entries across 15 versions & 2 rubygems

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