我有/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
其他信息:
/api
范围内答案 0 :(得分:0)
我认为POST调用的有效负载在post()
函数中,而您已经将它放入了team_path
帮助程序中。您可以尝试:
conn = post(conn, team_path(conn, :create), %{team: @team_attrs})
链接到文档以供参考: