Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider having Eras not complete eagerly #26

Open
jasongrlicky opened this issue Feb 2, 2018 · 0 comments
Open

Consider having Eras not complete eagerly #26

jasongrlicky opened this issue Feb 2, 2018 · 0 comments

Comments

@jasongrlicky
Copy link
Contributor

Right now Eras complete eagerly - that is, if you have .called_any() on an Expectation, for era completion purposes, it will behave as if it is a .called_once().

This isn't intuitive - we should accept any number of calls of that function before considering the era finished.

The end goal would be that something like the following test should pass:

#[test]
fn test_eras_do_not_complete_eagerly() {
    let mut e = Expectations::new();

    // Expectations
    e.expect::<(), ()>("c").called_any();
    e.then();
    e.expect::<(), ()>("d").called_once();
        
    // Calls
    e.was_called::<(), ()>("c", ()); // Does NOT complete the first era, unlike today
    e.was_called::<(), ()>("c", ()); // Completes first era
    e.was_called::<(), ()>("d", ()); // Completes second era
}

That said, we'll need to come up with a good solution for the following cases:

  • What happens when a called_any() is followed by a called_any() for the same method in the next era?

We may also need to rethink the way that Eras operate fundamentally. We could possibly also use this as an opportunity to create global expectations, or allow return/modifying behaviors to be set on a method level?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant