{"action":"opened","issue":{"url":"https://api.github.com/repos/eproxus/meck/issues/147","labels_url":"https://api.github.com/repos/eproxus/meck/issues/147/labels{/name}","comments_url":"https://api.github.com/repos/eproxus/meck/issues/147/comments","events_url":"https://api.github.com/repos/eproxus/meck/issues/147/events","html_url":"https://github.com/eproxus/meck/issues/147","id":92714765,"number":147,"title":"Expect different return values at different times","user":{"login":"doubleyou","id":217284,"avatar_url":"https://avatars.githubusercontent.com/u/217284?v=3","gravatar_id":"","url":"https://api.github.com/users/doubleyou","html_url":"https://github.com/doubleyou","followers_url":"https://api.github.com/users/doubleyou/followers","following_url":"https://api.github.com/users/doubleyou/following{/other_user}","gists_url":"https://api.github.com/users/doubleyou/gists{/gist_id}","starred_url":"https://api.github.com/users/doubleyou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doubleyou/subscriptions","organizations_url":"https://api.github.com/users/doubleyou/orgs","repos_url":"https://api.github.com/users/doubleyou/repos","events_url":"https://api.github.com/users/doubleyou/events{/privacy}","received_events_url":"https://api.github.com/users/doubleyou/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-02T19:22:54Z","updated_at":"2015-07-02T19:22:54Z","closed_at":null,"body":"Hi,\r\n\r\nConsider the following example. We want some mocked function to return different values in different cases. Normally, this is being done either using something like `meck:seq/1` or by calling `meck:expect/4` in-place.\r\n\r\nThe sequencing approach can be a problem if there's no determined mount of calls to be made. For example, when we have some periodic calls, or when we have a complex call tree that calls our mocked function not once or twice. We may not even care about the amount of function calls made, just the fact that its return value was always the defined one.\r\n\r\nCalling `meck:expect/4` in place is much better from the semantics perspective but it's painfully slow, as we recompile the module every time. As a result, simple tests may start taking 5-10 seconds instead of sub-seconds.\r\n\r\nIs it technically possible to use something like ETS tables for storing `meck:expect` table, or there were some technical limitations that made you require to recompile the module? I ended up having that ETS-based approach for some cases and now wonder if `meck:expect/4` could be changed to work this way, which is much faster, or another function like `meck:quick_expect/4` can be added as a wrapper, because this seems like a fairly common pattern.\r\n\r\nThanks!"}}