diff options
Diffstat (limited to 'spec/ruby/core/class/inherited_spec.rb')
| -rw-r--r-- | spec/ruby/core/class/inherited_spec.rb | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/spec/ruby/core/class/inherited_spec.rb b/spec/ruby/core/class/inherited_spec.rb index 356e46be7c..c9acc740a1 100644 --- a/spec/ruby/core/class/inherited_spec.rb +++ b/spec/ruby/core/class/inherited_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../fixtures/classes', __FILE__) +require_relative '../../spec_helper' +require_relative 'fixtures/classes' describe "Class.inherited" do @@ -92,11 +92,27 @@ describe "Class.inherited" do end class << top; private :inherited; end - lambda { Class.new(top) }.should_not raise_error + -> { Class.new(top) }.should_not.raise class << top; protected :inherited; end - lambda { Class.new(top) }.should_not raise_error + -> { Class.new(top) }.should_not.raise end -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 |
