# To make debugging spec test with stubbed :id objects in debugger possible.
require 'mocha/mock'
Mocha::Mock.class_eval <<-MOCHA
#alias_method :mock_respond_to, :respond_to?
#def respond_to?(symbol, include_private = false)
# mock_respond_to(symbol, include_private) || symbol == :object_id
#end
# the above approach would cause broken debugger loop due to error ''Exception in DebugThread loop: unexpected invocation: #<Mock:image1>.mock_respond_to(:object_id, false)''
# so we have to resort to copying codes
def respond_to?(symbol, include_private = false)
return true if symbol == :object_id
if @responder then
if @responder.method(:respond_to?).arity > 1
@responder.respond_to?(symbol, include_private)
else
@responder.respond_to?(symbol)
end
else
@everything_stubbed || @expectations.matches_method?(symbol)
end
end
MOCHA
Thanks
Hi.
Sorry it's taken so long to reply. This message somehow ended up in my spam filter.
I've added an issue [1] on Github for your question.
Regards, James.
[1] https://github.com/freerange/mocha/issues/139