Skip to content

Commit

Permalink
Add spec for defined? on constant with const_missing
Browse files Browse the repository at this point in the history
Make sure that `defined?` returns nil even if `const_missing` is
implemented in the parent.
  • Loading branch information
richardboehme committed Nov 8, 2024
1 parent bbcd077 commit 4cbc05a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions language/defined_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,14 @@
defined?(DefinedSpecs::Undefined).should be_nil
end

it "returns nil when the constant is not defined and the parent implements const_missing" do
def DefinedSpecs.const_missing(const)
const
end

defined?(DefinedSpecs::Undefined).should be_nil
end

it "does not call .const_missing if the constant is not defined" do
DefinedSpecs.should_not_receive(:const_missing)
defined?(DefinedSpecs::UnknownChild).should be_nil
Expand Down

0 comments on commit 4cbc05a

Please sign in to comment.