Source

puzzle_nodes / 13 / test / board_test.rb

require 'minitest/unit'
require 'minitest/autorun'
require './lib/board'

class BoardTest < MiniTest::Unit::TestCase
  def setup
    @input = <<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

  @board = Board.new @input
  end


  def test_board_reads_board_state_from_input
    assert_equal "bR", @board[0][0]
  end

  def test_algebraic_predicate
    assert @board.algebraic?(:a8), "Expected a8 to be algebraic, wasn't."
    assert @board.algebraic?(:g4), "Expected g4 to be algebraic, wasn't."
    refute @board.algebraic?(:d9), "Expected d9 not to be algebraic, was."
    refute @board.algebraic?(:n7), "Expected n7 not to be algebraic, was."
  end

  def test_board_responds_to_algebraic_methods
    assert_equal "bR", @board.a8
    assert_equal "wK", @board.e1
    assert_equal "wR", @board.h1
  end
end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.