Add a new spec for inherited

This commit is contained in:
Xavier Noria 2025-04-20 23:43:02 +02:00 committed by Jean Boussier
parent 80cf292c79
commit 5f3fb35a14
Notes: git 2025-04-23 05:10:30 +00:00

View File

@ -98,4 +98,21 @@ describe "Class.inherited" do
-> { Class.new(top) }.should_not raise_error
end
it "if the subclass is assigned to a constant, it is all set" do
ScratchPad.record []
parent = Class.new do
def self.inherited(subclass)
ScratchPad << defined?(self::C)
ScratchPad << const_defined?(:C)
ScratchPad << constants
ScratchPad << const_get(:C)
ScratchPad << subclass.name.match?(/\A#<Class:0x\w+>::C\z/)
end
end
class parent::C < parent; end
ScratchPad.recorded.should == ["constant", true, [:C], parent::C, true]
end
end