Sha256: 54ae0d1a7df32fd3b96ad5e9c65d903b914e02e64ef5e5aac4a5519af5318d9a

Contents?: true

Size: 1.16 KB

Versions: 36

Compression:

Stored size: 1.16 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper.rb'
require 'reek/module_context'
require 'reek/stop_context'

include Reek

describe ModuleContext do
  it 'should report module name for smell in method' do
    'module Fred; def simple(x) true; end; end'.should reek_of(:UncommunicativeName, /x/, /simple/, /Fred/)
  end

  it 'should not report module with empty class' do
    'module Fred; class Jim; end; end'.should_not reek
  end

  it 'should handle module with empty class' do
    stop = StopContext.new
    modctx = ModuleContext.create(stop, [:module, :Fred, []])
    modctx.find_module(Name.new(:Jim)).should be_nil
  end
end

describe ModuleContext do
  it 'should recognise global constant' do
    'module ::Global class Inside; end; end'.should_not reek
  end

  it 'should not find missing global constant' do
    element = ModuleContext.create(StopContext.new, [:module, [:colon3, :Global], nil])
    element.myself.should be_nil
  end

  it 'should find global constant' do
    module ::GlobalTestModule; end
    element = ModuleContext.create(StopContext.new, [:module, [:colon3, :GlobalTestModule], nil])
    element.myself.name.should == 'GlobalTestModule'
  end
end

Version data entries

36 entries across 36 versions & 3 rubygems

Version Path
kevinrutherford-reek-0.3.1.4 spec/reek/module_context_spec.rb
kevinrutherford-reek-0.3.1.5 spec/reek/module_context_spec.rb
kevinrutherford-reek-0.3.1.6 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.0.0 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.0.1 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.1.1 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.1.2.1 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.1.2 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.1.3.1 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.1.3.10 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.1.3.11 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.1.3.12 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.1.3.13 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.1.3.14 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.1.3.15 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.1.3.16 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.1.3.2 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.1.3.3 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.1.3.4 spec/reek/module_context_spec.rb
kevinrutherford-reek-1.1.3.5 spec/reek/module_context_spec.rb