lib/rspec/mocks/instance_method_stasher.rb in rspec-mocks-2.14.2 vs lib/rspec/mocks/instance_method_stasher.rb in rspec-mocks-2.14.3

- old
+ new

@@ -36,9 +36,15 @@ if ::UnboundMethod.method_defined?(:owner) # @private def method_owned_by_klass? owner = @klass.instance_method(@method).owner + + # On Ruby 2.0.0+ the owner of a method on a class which has been + # `prepend`ed may actually be an instance, e.g. + # `#<MyClass:0x007fbb94e3cd10>`, rather than the expected `MyClass`. + owner = owner.class unless owner.is_a? Class + # On 1.8 (and some 1.9s -- e.g. rubinius) aliased methods # can report the wrong owner. Example: # class MyClass # class << self # alias alternate_new new