From: "marcandre (Marc-Andre Lafortune)" Date: 2013-03-30T11:30:28+09:00 Subject: [ruby-core:53834] [ruby-trunk - Bug #8166][Feedback] Since r39628 rspec-mock's and_call_original fail with SystemStackError Issue #8166 has been updated by marcandre (Marc-Andre Lafortune). Status changed from Open to Feedback Assignee changed from marcandre (Marc-Andre Lafortune) to nagachika (Tomoyuki Chikanaga) Further study revealed that `and_call_original` does not work in some circumstances in Ruby 1.9/2.0 (see https://github.com/rspec/rspec-mocks/pull/258 ). In Ruby 2.1 this bug is not even present, because of the consistency of singleton_class.ancestors! I don't think it is easy to fix rspec-mock to pass the test I gave, as a direct consequence of singleton classes ancestors being hidden. I consider this a good example that the 2.1 behavior is superior, would you not agree? ---------------------------------------- Bug #8166: Since r39628 rspec-mock's and_call_original fail with SystemStackError https://bugs.ruby-lang.org/issues/8166#change-38043 Author: nagachika (Tomoyuki Chikanaga) Status: Feedback 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/