I'm new to elixir and phoenix and I wanted to doctest a newly created context (using mix phx.gen.context).
I have an Accounts context with a User schema.
I added to accounts_test.exs the following lines:
alias MyApp.Accounts.User
doctest MyApp.Accounts.User, import: true
And even fixed the default change_user documentation:
- %Ecto.Changeset{source: %User{}}
+ %Ecto.Changeset{data: %User{}}
But I still have many, many, errors and warnings, as if it was basically not made to be doctested...
For example, the default generated doc puts:
iex>
update_user(user, %{field: new_value})
{:ok, %User{}}
This would issue:
warning: variable "new_value" does not exist and is being expanded to "new_value()"...
warning: variable "user" does not exist and is being expanded to "user()"...
test/my_app/accounts_test.exs:45: undefined function new_value/0
test/my_app/accounts_test.exs:45: undefined function user/0
My question is: is there something I'm missing? Or is it generally not common to doctest one's context (which would explain why it doesn't work out-of-the-box)