Skip to content

Commit

Permalink
Tests fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bigardone committed Apr 24, 2016
1 parent 9658efa commit eca29ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions test/lib/game/board_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ defmodule Battleship.Game.BoardTest do
valid_ships
|> Enum.each(&Board.add_ship(@player_id, &1))

assert {:ok, %Board{grid: %{"99" => "O"}}} = Board.take_shot(@player_id, x: 9, y: 9)
assert {:ok, "O"} = Board.take_shot(@player_id, x: 9, y: 9)
end

test "taking a shot into a ship", %{valid_ships: valid_ships, hit_points: hit_points} do
Expand All @@ -71,6 +71,7 @@ defmodule Battleship.Game.BoardTest do

hit_points = hit_points - 1

assert {:ok, %Board{grid: %{"00" => "*"}, hit_points: ^hit_points}} = Board.take_shot(@player_id, x: 0, y: 0)
assert {:ok, "*"} = Board.take_shot(@player_id, x: 0, y: 0)
assert %Board{grid: %{"00" => "*"}, hit_points: ^hit_points} = Board.get_data(@player_id)
end
end
4 changes: 2 additions & 2 deletions test/lib/game_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ defmodule Battleship.GameTest do
assert_receive {:DOWN, ^ref, :process, ^pid, :normal}
end

test "updates rounds after a shot", %{id: id, attacker_id: attacker_id, defender_id: defender_id} do
test "updates turns after a shot", %{id: id, attacker_id: attacker_id, defender_id: defender_id} do
GameSupervisor.create_game(id)

valid_ships = [
Expand All @@ -68,6 +68,6 @@ defmodule Battleship.GameTest do

{:ok, game} = Game.player_shot(id, attacker_id, x: 0, y: 0)

assert [%{player_id: ^attacker_id, x: 0, y: 0}] = game.rounds
assert [%{player_id: ^attacker_id, x: 0, y: 0}] = game.turns
end
end

0 comments on commit eca29ba

Please sign in to comment.