Add a new spec for inherited
This commit is contained in:
parent
80cf292c79
commit
5f3fb35a14
Notes:
git
2025-04-23 05:10:30 +00:00
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user