diff --git a/spec/ruby/core/unboundmethod/fixtures/classes.rb b/spec/ruby/core/unboundmethod/fixtures/classes.rb index f2999671ca..0eb7a54f02 100644 --- a/spec/ruby/core/unboundmethod/fixtures/classes.rb +++ b/spec/ruby/core/unboundmethod/fixtures/classes.rb @@ -60,6 +60,11 @@ def self.class_method class Child1 < Parent; end class Child2 < Parent; end + class Child3 < Parent + class << self + alias_method :another_class_method, :class_method + end + end class A def baz(a, b) diff --git a/spec/ruby/core/unboundmethod/owner_spec.rb b/spec/ruby/core/unboundmethod/owner_spec.rb index 984016ec0a..eae76db234 100644 --- a/spec/ruby/core/unboundmethod/owner_spec.rb +++ b/spec/ruby/core/unboundmethod/owner_spec.rb @@ -18,5 +18,33 @@ UnboundMethodSpecs::Methods.new.method(:from_mod).owner.should == UnboundMethodSpecs::Mod end + ruby_version_is "" ... "1.9" do + + before :each do + @parent_singleton_class = class << UnboundMethodSpecs::Parent; self; end + @child_singleton_class = class << UnboundMethodSpecs::Child3; self; end + end + + it "returns the original owner for aliased methods" do + @child_singleton_class.instance_method(:class_method).owner.should == @parent_singleton_class + @child_singleton_class.instance_method(:another_class_method).owner.should == @parent_singleton_class + end + + end + + ruby_version_is "1.9" do + + before :each do + @parent_singleton_class = class << UnboundMethodSpecs::Parent; self; end + @child_singleton_class = class << UnboundMethodSpecs::Child3; self; end + end + + it "returns the new owner for aliased methods" do + @child_singleton_class.instance_method(:class_method).owner.should == @parent_singleton_class + @child_singleton_class.instance_method(:another_class_method).owner.should == @child_singleton_class + end + + end + end end