Sha256: 76f02f0cc6cd74ec08853b8e5c00398864f5a45c5d5d2437e824239e32f4010f

Contents?: true

Size: 830 Bytes

Versions: 1

Compression:

Stored size: 830 Bytes

Contents

require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))

describe Module do

  before(:all) do
    module Foo
      class Bar
      end
    end
    
    class Baz
    end
    
    class Bar
    end
  end

  it "should be able to get a recursive constant" do
    Object::find_const('Foo::Bar').should == Foo::Bar
  end

  it "should ignore get Constants from the Kernel namespace correctly" do
    Object::find_const('::Foo::Bar').should == ::Foo::Bar
  end

  it "should not cache unresolvable class string" do
    lambda { find_const('Foo::Bar::Baz') }.should raise_error(NameError)
    Object::send(:__nested_constants__).has_key?('Foo::Bar::Baz').should == false
  end
  
  it "should find relative constants" do
    Foo.find_const('Bar').should == Foo::Bar
    Foo.find_const('Baz').should == Baz
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
extlib-0.9.2 spec/module_spec.rb