method
stub_object
v8.0.0 -
Show latest stable
- Class:
ActiveSupport::Testing::SimpleStubs
stub_object(object, method_name, &block)public
Stubs object.method_name with the given block If the method is already stubbed, remove that stub so that removing this stub will restore the original implementation.
Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00 target = Time.zone.local(2004, 11, 24, 1, 4, 44) simple_stubs.stub_object(Time, :now) { at(target.to_i) } Time.current # => Wed, 24 Nov 2004 01:04:44 EST -05:00