pub struct MockSet { /* private fields */ }Expand description
The effective mock/spy set for one case run: the CLI/SDK-level declarations (first, so a test-local rule shadows a shared one — first match wins) followed by the case’s own, validated as a whole and compiled to the oneharness ruleset.
Implementations§
Source§impl MockSet
impl MockSet
Sourcepub fn build(
shared: &[MockDecl],
case: &[MockDecl],
spy_requested: bool,
) -> Result<MockSet>
pub fn build( shared: &[MockDecl], case: &[MockDecl], spy_requested: bool, ) -> Result<MockSet>
Build and validate the effective set. shared (CLI --mocks / SDK)
declarations come first, then the case’s own; names must be unique
across the whole set.
§Errors
Error::Invalid on any invalid declaration or a duplicate name.
Sourcepub fn rules(&self) -> Option<&Value>
pub fn rules(&self) -> Option<&Value>
The compiled oneharness ruleset, when any declaration intercepts.
Sourcepub fn resolve(&self, records: Vec<MockCall>) -> Vec<MockCall>
pub fn resolve(&self, records: Vec<MockCall>) -> Vec<MockCall>
Fill each record’s mock name from the rule index that intercepted it.
Sourcepub fn records_for<'r>(
&self,
name: &str,
records: &'r [MockCall],
) -> Result<Vec<&'r MockCall>>
pub fn records_for<'r>( &self, name: &str, records: &'r [MockCall], ) -> Result<Vec<&'r MockCall>>
The records belonging to the declaration named name: for a mock, the
calls its rule intercepted; for a spy, every record its matcher covers
(including calls other rules intercepted — a spy observes everything).
§Errors
Error::Invalid when no declaration has that name (listing the
declared names, so a typo is caught loudly instead of matching nothing).