Source

puzzle_nodes / 13 / test / pawn_test.rb

Full commit
require 'minitest/unit'
require 'minitest/autorun'
require './lib/board'
require './lib/piece'
require './lib/piece/pawn'

class PawnTest < MiniTest::Unit::TestCase
  include Piece

  def setup
    @board = Board.new <<BOARD
bR bN bB bQ bK bB bN bR
bP bP bP bP bP bP bP bP
-- -- -- -- -- -- -- --
-- -- -- -- -- -- -- --
-- -- -- -- -- -- -- --
-- -- -- -- -- -- -- --
wP wP wP wP wP wP wP wP
wR wN wB wQ wK wB wN wR
BOARD

    @white_pawn = Pawn.new 'wP', 49, @board
  end

  def test_pawns_move_straight_ahead
    assert_includes @white_pawn.destinations, :a3
  end

  def test_pawns_can_move_two_squares_in_first_turn
    assert_includes @white_pawn.destinations, :a4
  end

  def test_pawns_can_capture_diagonally
    board = Board.new <<BOARD
bR bN bB bQ bK bB bN bR
bP bP bP bP bP bP bP bP
-- -- -- -- -- -- -- --
-- -- -- -- -- -- -- --
-- -- -- -- -- -- -- --
bP -- -- -- -- -- -- --
wP wP wP wP wP wP wP wP
wR wN wB wQ wK wB wN wR
BOARD
    pawn = Pawn.new 'w', 49, board
  end
end