   test "syncs with code server" do
     assert Phoenix.CodeReloader.Server.sync == :ok
 
-    # Even in case of crashes, it works.
+    # Suspend so we can monitor the process until we get a reply.
+    # There is an inherent race condition here in that the process
+    # may die before we request but the code should work in both
+    # cases, so we are fine.
     :sys.suspend(Phoenix.CodeReloader.Server)
+    ref = Process.monitor(Phoenix.CodeReloader.Server)
 
     Task.start_link(fn ->
       Phoenix.CodeReloader.Server

    end)

    assert Phoenix.CodeReloader.Server.sync == :ok
  end

  test "reloads on every request" do

    assert conn.resp_body =~ "CompileError"
    assert conn.resp_body =~ "Compilation error"
  end

  defp wait_until_is_up(process) do
    if Process.whereis(process) do
      :ok
    else
      Process.sleep(10)
      wait_until_is_up(process)
    end
  end
end
