diff options
Diffstat (limited to 'examples/basic.rs')
-rw-r--r-- | examples/basic.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/examples/basic.rs b/examples/basic.rs index a157413..01688f5 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -1,8 +1,9 @@ use ridicule::mock; +use ridicule::predicate::{always, eq}; -trait Foo: Sized +trait Foo { - fn bar(&self, num: u128) -> &Self; + fn bar(&self, num: u128, text: &str); } mock! { @@ -10,7 +11,7 @@ mock! { impl Foo for MockFoo { - fn bar(&self, num: u128) -> &Self; + fn bar(&self, num: u128, text: &str); } } @@ -18,11 +19,12 @@ fn main() { let mut mock_foo = MockFoo::new(); - mock_foo.expect_bar().returning(|me, num| { - println!("bar was called with {num}"); + mock_foo + .expect_bar() + .with(eq(1234), always()) + .returning(|_, num, text| { + println!("bar was called with {num} and '{text}'"); + }); - me - }); - - mock_foo.bar(123); + mock_foo.bar(1234, "Hello"); } |