class MiniTest::Mock

def method_missing(sym, *args) # :nodoc:

:nodoc:
def method_missing(sym, *args) # :nodoc:
  expected = @expected_calls[sym]
  unless expected then
    raise NoMethodError, "unmocked method %p, expected one of %p" %
      [sym, @expected_calls.keys.sort_by(&:to_s)]
  end
  expected_args, retval = expected[:args], expected[:retval]
  unless expected_args.size == args.size
    raise ArgumentError, "mocked method %p expects %d arguments, got %d" %
      [sym, expected[:args].size, args.size]
  end
  @actual_calls[sym] << {
    :retval => retval,
    :args => expected_args.zip(args).map { |mod, a| mod === a ? mod : a }
  }
  retval
end