Skip to content

Commit

Permalink
Add specs for owners of aliased methods in 1.8 and 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
dbussink committed Feb 5, 2013
1 parent 74dfe98 commit c2631fe
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spec/ruby/core/unboundmethod/fixtures/classes.rb
Expand Up @@ -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)
Expand Down
28 changes: 28 additions & 0 deletions spec/ruby/core/unboundmethod/owner_spec.rb
Expand Up @@ -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

0 comments on commit c2631fe

Please sign in to comment.