Hi Rosa, thanks for the proposal!
My main concern with this approach is that the doctests are no longer "plug and play". I can no longer copy and paste them into IEx and have them work. Passing the context can be even more confusing, because you may end-up referencing things like `context.test`, which are hard to replicate on IEx.
What I have done in these cases is to have an explicit module that I call with a note in the docs:
Assuming your application has a MyExampleApp.client/0 that returns a MyLibrary.Client,
you can do:
iex> client = MyExampleApp.client()
iex> MyLibrary.call(client, :foo)
or:
Assuming your application has a MyExampleApp.setup_some_args/0 that adds some
fixtures to the database:
iex> client = MyExampleApp.setup_some_orgs()
iex> MyLibrary.run_query(some_qiery)
Then in my tests I define the MyExampleApp satisfying the conditions of the tests.