неопределенный _path после теста смеси - PullRequest
0 голосов
/ 11 октября 2018

У меня есть маршруты /teams и путь team_path через mix phx.routes.Однако я получаю undefined function team_path/3

ниже мой тестовый код:

describe "create team" do
   test "renders team when data is valid", %{conn: conn} do
      conn = post(conn, team_path(conn, :create, team: @team_attrs))

      assert %{"id" => id} = json_response(conn, 201)["data"]
    end

    test "renders errors when data is invalid", %{conn: conn} do
      conn = post(conn, team_path(conn, :create, team: @invalid_attrs))
      assert json_response(conn, 400)["errors"] != %{}
    end
  end

Дополнительная информация:

  • Phoenix 1.4-beta
  • * Phoenix_swagger установлен
  • , это API, так что все в рамках /api

1 Ответ

0 голосов
/ 11 октября 2018

Я думаю, что полезная нагрузка для вызова POST идет в функции post(), а вы поместили ее в помощник team_path.Не могли бы вы попробовать:

conn = post(conn, team_path(conn, :create), %{team: @team_attrs})

Ссылка на документы для справки:

https://hexdocs.pm/phoenix/Phoenix.ConnTest.html#post/3

...