class ActiveSupport::Testing::SimpleStubs

def stub_object(object, method_name, &block)

Time.current # => Wed, 24 Nov 2004 01:04:44 EST -05:00
simple_stubs.stub_object(Time, :now) { at(target.to_i) }
target = Time.zone.local(2004, 11, 24, 1, 4, 44)
Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
so that removing this stub will restore the original implementation.
If the method is already stubbed, remove that stub
Stubs object.method_name with the given block
def stub_object(object, method_name, &block)
  if stub = stubbing(object, method_name)
    unstub_object(stub)
  end
  new_name = "__simple_stub__#{method_name}"
  @stubs[object.object_id][method_name] = Stub.new(object, method_name, new_name)
  object.singleton_class.alias_method new_name, method_name
  object.define_singleton_method(method_name, &block)
end