-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
Promote meck_history:result to meck API...? #249
Comments
Yeah, good point. There is a risk of polluting the API with a lot of very specific functions that could perhaps be generalized a bit. What do you think about adding a new function that somehow grabs a function call from the history using some nice API (like |
I'm not quite sure what you're suggesting here. Are you suggesting adding (for the sake of argument) Or something else? I quite like the |
I guess I'm arguing for soft-deprecating I see it as meck:history().
% [{<0.332.0>,{foo,bar,[a,b]},ok},
% {<0.332.0>,{foo,bar,[c,d]},ok},
% {<0.332.0>,
% {foo,baz,[wat]},
% error,some_error,
% [{meck_ret_spec,eval_result,4,[{file,"src/meck_ret_spec.erl"},{line,93}]},
% {foo,baz,[wat]}]},
% {<0.345.0>,{foo,bar,[x,y]},ok}]
meck:calls(foo, bar, 2).
% [{<0.332.0>,{foo,bar,[a,b]},ok},
% {<0.332.0>,{foo,bar,[c,d]},ok},
% {<0.345.0>,{foo,bar,[x,y]},ok}]
meck:call(foo, bar, 2, last).
% {<0.345.0>,{foo,bar,[x,y]},ok}
meck:call(foo, bar, 2, first).
% {<0.345.0>,{foo,bar,[a,b]},ok}
meck:calls(foo, bar, ['_', d])
% [{<0.332.0>,{foo,bar,[c,d]},ok}]
meck:call(foo, bar, ['_', d]) % implies 'last'
% {<0.345.0>,{foo,bar,[x,y]},ok} (Totally made up proposal, so names and arguments are not that seriously suggested, yet). With something like that, if you want the first argument and the result you could do: {_From, [First|_], Result} = meck:call(foo, bar, ['_', d]) To get the nth argument from the argument list, you could use |
Another long-standing idea I have for a new version of the history API is to include timestamps too, but maybe this is scope creep at this time |
I was looking for a way to grab the result of a mocked call. Currently, I'm just peeking into
meck:history()
.So I went to implement something like
meck:capture(..., result)
, when I noticed thatmeck_history:result()
exists. It was added in #163.But it was demoted from the top-level
meck
API. I think this was a mistake -- it ought to be at the same level of abstraction asmeck:capture
.Can we put it back? Or can we make
meck:capture
takeArgNum | result
...?The text was updated successfully, but these errors were encountered: