mercredi 6 mai 2015

Is it possible to stub(mock?) Ecto.UUID.generate in an ExUnit test?

I'm using Ecto.UUID.generate to create a random token on a user model.

In my ExUnit test, I want to test the controller that calls the creation route, however because the token is always random, I can't deterministically test the result.

Ideally, I want to be able to stub the Ecto.UUID.generate in my test so it always creates the same UUID so I can test the response correctly.

Thanks :)

Aucun commentaire:

Enregistrer un commentaire