Wait for a number of function calls #81

Closed
horkhe opened this Issue Oct 24, 2012 · 2 comments

Comments

Projects
None yet
2 participants
@horkhe
Contributor

horkhe commented Oct 24, 2012

It would be great if we could wait for a particular function of a mocked module to be called a particular number of times with particular parameters. E.g.

meck:new(some_mod, [passthrough]),
....
meck:wait_4_call(3, {some_mod, f1, [blah, '_', 10]}, 10000).

where

-spec wait_4_call(CalledTimes :: non_neg_integer(),
                  {module(), func(), args_pattern()},
                  Timeout :: erlang:timeout()) ->
        ok.

The wait_4_call should fail if the call pattern, that we are waiting upon, is not met within the time specified by Timeout.

I personally need this capability to use in my functional tests to get rid of ugly timer:sleep/1.

@eproxus

This comment has been minimized.

Show comment
Hide comment
@eproxus

eproxus Oct 24, 2012

Owner

This is a really good idea!

Maybe we could call it wait only? (Also, timeout should be optional)

Owner

eproxus commented Oct 24, 2012

This is a really good idea!

Maybe we could call it wait only? (Also, timeout should be optional)

@horkhe

This comment has been minimized.

Show comment
Hide comment
@horkhe

horkhe Oct 24, 2012

Contributor

I will start working on it as soon as finish splitting of the meck module.

Contributor

horkhe commented Oct 24, 2012

I will start working on it as soon as finish splitting of the meck module.

aaron-thompson added a commit to aaron-thompson/meck that referenced this issue Aug 16, 2013

@eproxus eproxus closed this in ed44176 Aug 17, 2013

eproxus added a commit that referenced this issue Aug 17, 2013

Merge pull request #99 from horkhe/feature/wait
Wait for a number of calls feature (#81 / #99)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment