Sha256: ccefd22d2f6ea0ee71bd6ef615767f4600f4348097e52f7ca8a99ee0de911b36
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe Module do before(:all) do module Foo module Bar module Noo module Too end end end class Zed end end class Baz end class Bar end end it "should raise NameError for a missing constant" do lambda { Foo.find_const('Moo') }.should raise_error(NameError) lambda { Object.find_const('MissingConstant') }.should raise_error(NameError) 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 find relative constants" do Foo.find_const('Bar').should == Foo::Bar Foo.find_const('Baz').should == Baz end it "should find sibling constants" do Foo::Bar.find_const("Zed").should == Foo::Zed end it "should find nested constants on nested constants" do Foo::Bar.find_const('Noo::Too') end it "should be able to deal with constants being added and removed" do Object.find_const('Bar') # First we load Bar with find_const Object.module_eval { remove_const('Bar') } # Now we delete it module Bar; end; # Now we redefine it Object.find_const('Bar').should == Bar end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
extlib-0.9.3 | spec/module_spec.rb |
thorero-0.9.4 | spec/module_spec.rb |