class Spectator::ValueMockRegistry(T)
Overview
Stores collections of stubs for mocked value (struct) types.
T is the type of value to track.
This type is intended for all mocked struct types that have functionality "injected." That is, the type itself has mock functionality bolted on. Adding instance members should be avoided, for instance, it could mess up serialization. This registry works around that by mapping mocks (via their raw memory content) to a collection of stubs. Doing so prevents adding data to the mocked type.
Defined in:
spectator/mocks/value_mock_registry.crConstructors
-
.new
Creates an empty registry.
Instance Method Summary
-
#[](object : T)
Retrieves all stubs defined for a mocked object.
-
#[]?(object : T)
Retrieves all stubs defined for a mocked object or nil if the object isn't mocked yet.
-
#delete(object : T) : Nil
Clears all stubs defined for a mocked object.
-
#fetch(object : T, & : -> Array(Stub))
Retrieves all stubs defined for a mocked object.
Instance methods inherited from class Object
should(matcher : Spectator::Matchers::TypeMatcher(U), message = nil, *, _file = __FILE__, _line = __LINE__) forall Ushould(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should, should_eventually(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should_eventually, should_never(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should_never, should_not(matcher : Spectator::Matchers::TypeMatcher(U), message = nil, *, _file = __FILE__, _line = __LINE__) forall U
should_not(matcher : Spectator::Matchers::NilMatcher, message = nil, *, _file = __FILE__, _line = __LINE__)
should_not(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should_not
Constructor Detail
Instance Method Detail
Retrieves all stubs defined for a mocked object or nil if the object isn't mocked yet.
Retrieves all stubs defined for a mocked object.
Yields to the block on the first retrieval. This allows a mock to populate the registry with initial stubs.