Created
April 11, 2011 18:05
-
-
Save dreid/913953 to your computer and use it in GitHub Desktop.
A rather convoluted mechanism for getting subsequent calls to a mecked function to return different results.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(multiple_expect_results). | |
-include_lib("eunit/include/eunit.hrl"). | |
multiple_results_test() -> | |
ok = meck:new(some_mod), | |
meck:expect(some_mod, get_pid, fun() -> self() end), | |
meck:expect(some_mod, some_fun, | |
fun() -> | |
receive | |
{{some_mod, some_fun}, Result} -> | |
Result | |
end | |
end), | |
ModPid = some_mod:get_pid(), | |
ModPid ! {{some_mod, some_fun}, a}, | |
ModPid ! {{some_mod, some_fun}, b}, | |
ModPid ! {{some_mod, some_fun}, c}, | |
?assertEqual(a, some_mod:some_fun()), | |
?assertEqual(b, some_mod:some_fun()), | |
?assertEqual(c, some_mod:some_fun()). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment