1
0
mirror of https://github.com/danbee/chess synced 2025-03-04 08:39:06 +00:00

Fix the fucking tests

This commit is contained in:
Daniel Barber 2016-12-10 23:28:18 +00:00
parent b5c7695344
commit 34a3d48260
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
6 changed files with 6 additions and 48 deletions

View File

@ -12,8 +12,6 @@ config :logger, level: :warn
# Configure your database
config :chess, Chess.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "postgres",
database: "chess_test",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox

View File

@ -2,8 +2,7 @@ defmodule Chess.GameControllerTest do
use Chess.ConnCase
alias Chess.Game
@valid_attrs %{board: %{}}
@invalid_attrs %{}
@valid_attrs %{}
test "lists all entries on index", %{conn: conn} do
conn = get conn, game_path(conn, :index)
@ -12,19 +11,14 @@ defmodule Chess.GameControllerTest do
test "creates resource and redirects when data is valid", %{conn: conn} do
conn = post conn, game_path(conn, :create), game: @valid_attrs
assert redirected_to(conn) == game_path(conn, :index)
assert Repo.get_by(Game, @valid_attrs)
end
test "does not create resource and renders errors when data is invalid", %{conn: conn} do
conn = post conn, game_path(conn, :create), game: @invalid_attrs
assert html_response(conn, 200) =~ "New game"
game = Repo.one(Game)
assert redirected_to(conn) == game_path(conn, :show, game)
end
test "shows chosen resource", %{conn: conn} do
game = Repo.insert! %Game{}
conn = get conn, game_path(conn, :show, game)
assert html_response(conn, 200) =~ "Show game"
assert html_response(conn, 200) =~ "<div id=\"app\" data-game-id=\"#{game.id}\">"
end
test "renders page not found when id is nonexistent", %{conn: conn} do
@ -33,25 +27,6 @@ defmodule Chess.GameControllerTest do
end
end
test "renders form for editing chosen resource", %{conn: conn} do
game = Repo.insert! %Game{}
conn = get conn, game_path(conn, :edit, game)
assert html_response(conn, 200) =~ "Edit game"
end
test "updates chosen resource and redirects when data is valid", %{conn: conn} do
game = Repo.insert! %Game{}
conn = put conn, game_path(conn, :update, game), game: @valid_attrs
assert redirected_to(conn) == game_path(conn, :show, game)
assert Repo.get_by(Game, @valid_attrs)
end
test "does not update chosen resource and renders errors when data is invalid", %{conn: conn} do
game = Repo.insert! %Game{}
conn = put conn, game_path(conn, :update, game), game: @invalid_attrs
assert html_response(conn, 200) =~ "Edit game"
end
test "deletes chosen resource", %{conn: conn} do
game = Repo.insert! %Game{}
conn = delete conn, game_path(conn, :delete, game)

View File

@ -1,8 +0,0 @@
defmodule Chess.PageControllerTest do
use Chess.ConnCase
test "GET /", %{conn: conn} do
conn = get conn, "/"
assert html_response(conn, 200) =~ "Welcome to Phoenix!"
end
end

View File

@ -1,7 +0,0 @@
defmodule Chess.PageController do
use Chess.Web, :controller
def index(conn, _params) do
render conn, "index.html"
end
end

View File

@ -16,7 +16,7 @@ defmodule Chess.Router do
scope "/", Chess do
pipe_through :browser # Use the default browser stack
get "/", PageController, :index
get "/", GameController, :index
resources "/games", GameController, only: [:create, :show, :delete]
end

View File

@ -15,7 +15,7 @@
</tbody>
</table>
<%= form_for @changeset, game_path(@conn, :create), fn f -> %>
<%= form_for @changeset, game_path(@conn, :create), fn _f -> %>
<div class="form-group">
<%= submit "Create game", class: "btn btn-primary" %>
</div>