Not sure about this because Double Ruby https://github.com/btakita/rr seems able to do this:
require 'rubygems' require 'test/unit' require 'rr' extend RR::Adapters::RRMethods class MockTest < Test::Unit::TestCase include RR::Adapters::TestUnit def test_can_mock_c_method a = [1,5,3] mock(a).sort{'foo!'} assert_equal 'foo!', a.sort end end
This uses MRI 1.8.7, and as far as I can tell, sorting # sort and Array # is implemented in C. Please correct me if I am wrong.
source share