jjh42 / mock

Mocking library for Elixir language
MIT License
639 stars 81 forks source link

Feature Request: Capture arguments #105

Open spencerdcarlson opened 4 years ago

spencerdcarlson commented 4 years ago

Sometimes I need to capture a mocked function's arguments and then compare them to the nth time that that function was called. It was able to accomplish this by dropping down to :meck but it would be nice if there were a helper macro / function

Workaround Example

# something called MyMockedModule.myfunc 2 times 
# and I want to make sure that the params are the same both times
[{_, {_, :myfunc, args0}, _}, {_, {_, :myfunc, args1}, _}] =
        unquote(MyMockedModule)
        |> :meck.history()

assert Map.equal?(args0, args1)