From: "jacknagel (Jack Nagel)" Date: 2013-12-18T02:43:43+09:00 Subject: [ruby-core:59158] [ruby-trunk - Bug #8817] Method#owner on prepended classes is an instance rather than Class/Method Issue #8817 has been updated by jacknagel (Jack Nagel). This appears to have been fixed by r44175. Can it be backported (perhaps with a regression test for this specific bug)? ---------------------------------------- Bug #8817: Method#owner on prepended classes is an instance rather than Class/Method https://bugs.ruby-lang.org/issues/8817#change-43722 Author: soulcutter (Bradley Schaefer) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0] Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN rdoc indicates that Method#owner will return a class or module that defines a method. http://www.ruby-doc.org/core-2.0/Method.html#method-i-owner For classes that have prepended modules, the owner is actually an instance. Example code: module Mod; end class Foo prepend Mod def foo; 'foo'; end end owner = Foo.instance_method(:foo).owner puts "Method#owner on a prepended class instance_method: #{owner.inspect}" #=> # puts "Class?: #{owner.is_a? Class}" #=> false puts "Module?: #{owner.is_a? Module}" #=> false This had the effect of breaking stubbing in rspec (https://github.com/rspec/rspec-mocks/pull/385) , though a workaround is that the expected Class/Module can be retrieved by asking for the returned object's class. -- http://bugs.ruby-lang.org/