From: "nagachika (Tomoyuki Chikanaga)" Date: 2013-03-30T23:13:42+09:00 Subject: [ruby-core:53844] [ruby-trunk - Bug #8166][Rejected] Since r39628 rspec-mock's and_call_original fail with SystemStackError Issue #8166 has been updated by nagachika (Tomoyuki Chikanaga). Status changed from Feedback to Rejected Hello, Thank you for your investigation. > Do you believe that only because you want to avoid all compatibility issues, or are there other reasons? Just because for compatibility issues. And I agree it is more consistent and helpful that the singleton class exists in ancestors in case of self is a singleton class. My concern was about Module#prepend with a singleton class. How to mock o.m1 in the following example? module M def m1 "M#m1" end end o = Object.new o.singleton_class.module_eval do def m1 "C#m1" end prepend M end o.m1 # => "M#m1" o.ancestors # => [M, #>, Object, Kernel, BasicObject] But, it was not the issue from the change made by r39628, and problem of rspec-mock. Sorry, I was confused. I'll close the ticket in a while. ---------------------------------------- Bug #8166: Since r39628 rspec-mock's and_call_original fail with SystemStackError https://bugs.ruby-lang.org/issues/8166#change-38054 Author: nagachika (Tomoyuki Chikanaga) Status: Rejected Priority: Normal Assignee: nagachika (Tomoyuki Chikanaga) Category: core Target version: current: 2.1.0 ruby -v: ruby 2.1.0dev (2013-03-24 trunk 39908) [x86_64-darwin10.8.0] Hello, By r39628 [Feature 8035], Module#ancestors for a singleton class contains singleton class itself. It introduce a compatibility problem with rspec-mock's RSpec::Mocks::MessageExpectation#and_call_original. and_call_original uses Module#ancestors to find the original method overridden by a singleton method. Because ancestors contains singleton class itself, `original_method' return stub method and fall into infinite recursive call. I think hiding singleton class from ancestors is better even when a modules is pretended. -- http://bugs.ruby-lang.org/