Ability to assert arguments of specific function invocation
For the situation where a function is called 10 times, is there a way to assert what args the 6th invocation of the function was called with?
assert_called(MyModule.my_function(session_arg), 10)
In this example session_arg will bind to the last matching call, which allows me to do asserts against that. However, I want to assert the 6th call. Is this possible, and if not, could it be added as a feature?
For more advanced use cases like this you can make use of history/2 https://hexdocs.pm/patch/Patch.html#history/2 which provides all the calls that have been seen. So for example you could do
{:my_function, [session_arg]} =
MyModule
|> history()
|> Enum.filter(fn {func, args} -> func == :my_function end)
|> Enum.at(5)
assert session_arg == expected_session_arg
@Arsenalist I'm going to close this out as answered, but if you still require assistance please feel free to open a new issue.