method
stub_object
v5.1.7 -
Show latest stable
- Class:
ActiveSupport::Testing::SimpleStubs
stub_object(object, method_name, &block)public
No documentation available.
# File activesupport/lib/active_support/testing/time_helpers.rb, line 14
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.send :alias_method, new_name, method_name
object.define_singleton_method(method_name, &block)
end