pub fn spy<I>(clauses: I) -> Unimock where
I: IntoIterator<Item = Clause>,
Expand description
Construct a unimock instance that works like a spy, where every clause acts as an override over the default behaviour, which is to hit “real world” code using the Unmock feature.
Example
#[unimock(unmocked=[real_foo])]
trait Trait {
fn foo(&self);
}
fn real_foo<T: std::any::Any>(_: &T) {
println!("real thing");
}
// Spy objects that spies on nothing:
spy(None).foo();
spy([]).foo();
// prints "real thing" x 2
spy(Some(Trait__foo::next_call(matching!()).returns(()).once().in_order())).foo();
// does not print
// spy object that prevents the real