dashbitco / mox

Mocks and explicit contracts in Elixir
1.35k stars 77 forks source link

Note what args were passed on UnexpectedCallError #54

Closed TheFirstAvenger closed 5 years ago

TheFirstAvenger commented 5 years ago

When building out tests, it would be helpful to have the UnexpectedCallError note what args were passed to the unexpected function. The args are available here: https://github.com/plataformatec/mox/blob/master/lib/mox.ex#L551

Not sure if this should be in a separate logger call or in the error.

This would be helpful when specifying exact expected args as here: https://github.com/TheFirstAvenger/ironman/blob/fac59ddeb804510f0620cc009df955a28286834a/test/support/mox_helpers.ex#L26

As a workaround, I have been specifying my own catch-all for each moxed call, but that needs to be manually added to each test case after the other expects: https://github.com/TheFirstAvenger/ironman/blob/fac59ddeb804510f0620cc009df955a28286834a/test/support/mox_helpers.ex#L59

josevalim commented 5 years ago

@TheFirstAvenger a PR that includes the arguments on the message would be very welcome!

TheFirstAvenger commented 5 years ago

@josevalim 👍 PR submitted