Skip to content

Commit

Permalink
Add a few more specs for defined? with scoped constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Oct 28, 2015
1 parent b99f44c commit 591ff4f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions language/defined_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -763,10 +763,22 @@
defined?(DefinedSpecs::Child::B).should be_nil
end

it "returns nil when a constant is scoped to an undefined constant" do
defined?(Undefined::Object).should be_nil
end

it "returns nil when the undefined constant is scoped to an undefined constant" do
defined?(DefinedSpecs::Undefined::Undefined).should be_nil
end

it "returns nil when a constant is defined on top-level but not on the module" do
defined?(DefinedSpecs::String).should be_nil
end

it "returns 'constant' when a constant is defined on top-level but not on the class" do
defined?(DefinedSpecs::Basic::String).should == "constant"
end

it "returns 'constant' if the scoped-scoped constant is defined" do
defined?(DefinedSpecs::Child::A).should == "constant"
end
Expand Down

0 comments on commit 591ff4f

Please sign in to comment.