class Mocks::Registry
- Mocks::Registry
- Reference
- Object
Overview
Stores and retrieves method stubs and calls for multiple objects.
Reference-based objects are tracked by their #object_id
(memory address).
Value-based objects are tracked by their byte-wise representation.
NOTE This approach does not work for mutable values, and their use is generally discouraged. This also implies that two separate values with the same content will be tracked as the same object.
See: https://crystal-lang.org/reference/1.7/syntax_and_semantics/structs.html
Defined in:
mocks/registry.crInstance Method Summary
-
#add_call(object, call : Call) : Nil
Records a method call made to an object.
-
#add_stub(object, stub : Stub) : Nil
Adds a stub for an object.
-
#calls(object) : Enumerable
Retrieves all method calls made to an object.
-
#clear(object) : Nil
Removes all stored stubs and calls for the specified object.
-
#clear : Nil
Removes all stored stubs and calls for all objects.
-
#clear_calls(object) : Nil
Removes all previously recorded method calls for an object.
-
#clear_stubs(object) : Nil
Removes all previously stubs added for an object.
-
#find_stub(object, call : Call) : Stub | Nil
Finds a stub suitable stub for a method call.
-
#has_stub?(object, method_name : Symbol)
Checks if an object has a stub configured for the specified method.
-
#remove_stub(object, stub : Stub) : Nil
Removes a stub from an object.
Instance Method Detail
Finds a stub suitable stub for a method call. Returns nil if no stub was found. Stubs are searched in reverse order so that newly define stubs take precedence.
Checks if an object has a stub configured for the specified method.