class Spectator::Mocks::Registry
- Spectator::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:
spectator/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.
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.