Skip to content

Commit f9aef01

Browse files
fxnandrykonchin
authored andcommitted
Add a new spec for inherited
1 parent fbf66bb commit f9aef01

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

core/class/inherited_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,21 @@ class << top; protected :inherited; end
9898
-> { Class.new(top) }.should_not raise_error
9999
end
100100

101+
it "if the subclass is assigned to a constant, it is all set" do
102+
ScratchPad.record []
103+
104+
parent = Class.new do
105+
def self.inherited(subclass)
106+
ScratchPad << defined?(self::C)
107+
ScratchPad << const_defined?(:C)
108+
ScratchPad << constants
109+
ScratchPad << const_get(:C)
110+
ScratchPad << subclass.name.match?(/\A#<Class:0x\w+>::C\z/)
111+
end
112+
end
113+
114+
class parent::C < parent; end
115+
116+
ScratchPad.recorded.should == ["constant", true, [:C], parent::C, true]
117+
end
101118
end

0 commit comments

Comments
 (0)