seattlerb/minitest — Issue #100: Undef'ing methods breaks on Rubinius
Author: dbussink
Created: 2012-02-27 08:37:06+00:00
State: open

The mocks that minitest defines, break Kernel#inspect on Rubinius. The problem is with the following lines:

https://github.com/seattlerb/minitest/blob/master/lib/minitest/mock.rb#L15-19

Here methods that Rubinius uses internally for inspecting objects are undefined, such as Object#tainted? to set the tainted status of the resulting inspect string. Other methods are for example Object#== that is used for inspecting Hash instances, which breaks when there are Mock objects stored in a Hash.

This issue results in backtraces such as the following:

NoMethodError: unmocked method :tainted?, expected one of [:rpush]
kernel/common/kernel.rb:329:in `inspect'
kernel/common/hash19.rb:510:in `inspect'
kernel/common/hash19.rb:391:in `each_item'
kernel/common/hash19.rb:507:in `inspect'
kernel/common/thread.rb:52:in `detect_recursion'
kernel/common/hash19.rb:506:in `inspect'
kernel/common/hash19.rb:415:in `each_key'
kernel/common/hash19.rb:391:in `each_item'
kernel/common/hash19.rb:415:in `each_key'
../sidekiq/test/test_extensions.rb:41:in `TestExtensions'
kernel/bootstrap/array19.rb:18:in `map'
kernel/bootstrap/array19.rb:18:in `map'
kernel/bootstrap/array.rb:68:in `each'
kernel/loader.rb:712:in `run_at_exits'
kernel/loader.rb:732:in `epilogue'
kernel/loader.rb:863:in `main'

Adding more methods to the skip list seems like a bit of a brittle solution to me and having to prefix everything in Rubinius with __ also doesn't seem like a very viable solution, especially for cases like Object#==. I'm not really sure about what would be a proper way to fix this, but wanted to bring this issue to the attention.