Skip to content

Instantly share code, notes, and snippets.

Created February 20, 2012 22:11
What would you like to do?
Mocha VS MiniTest::Mock and SimpleDelegate VS SimpleMock
require 'benchmark'
require 'delegate'
require 'mocha'
require 'simple_mock' do |x| :mocha do
array = [1]
array.expects(:push).with(2).returns([1, 2])
end :delegator do
array = [1]
mock = { def push(*args); [1, 2]; end }.new(array)
end :simple_mock do
array = [1]
mock =, [1, 2], [2])
user system total real
mocha: 0.000000 0.000000 0.000000 (0.000279)
simple_delegator: 0.000000 0.000000 0.000000 (0.000029)
simple_mock: 0.000000 0.000000 0.000000 (0.000057)
Copy link

chadoh commented May 15, 2012

I couldn't get to work like that. As far as I could tell, the argument to bm is the label width. It no effect in getting the tests to run multiple times for me. See my fork to see what did work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment