coherence_demo icon indicating copy to clipboard operation
coherence_demo copied to clipboard

Fix Issue #8: Failing Test Cases

Open SiriusDely opened this issue 7 years ago • 4 comments

SiriusDely avatar Oct 29 '17 04:10 SiriusDely

Your solution is to run post(session_path(conn, :create), %{session: @user_attrs}) before every request in the tests. While it works, it's also verbose and repetitive.

Wouldn't it be better to build upon the original solution, using a setup function?

zwippie avatar Dec 10 '17 16:12 zwippie

Update:

The authors solution (that doesn't work anymore) combined with your solution is working. Add the following setup block to the controller test file and all the post calls in every test can now be removed:

  setup %{conn: conn} do
    user =
      User.changeset(%User{}, @user_attrs)
      |> Medox.Repo.insert!
    conn = post(conn, session_path(conn, :create), %{session: @user_attrs})
    {:ok, conn: conn, user: user}
  end

zwippie avatar Dec 10 '17 16:12 zwippie

Hi @zwippie thank you for your suggestion. Really appreciated.

I have updated this PR.

SiriusDely avatar Dec 25 '17 04:12 SiriusDely

@siriusdely You're welcome. In the meantime I've also found another workaround, as discussed in this related issue.

zwippie avatar Dec 26 '17 15:12 zwippie