require 'spec_helper'

describe TicTacToe::Core::Game do

  let(:player) { mock_player }
  let(:board) { TicTacToe::Core::Board.empty_board }
  let(:game) { test_game }

  def mock_player
    instance_double("TicTacToe::Player::Human").tap do |player|
      allow(player).to receive(:set_marks)
      allow(player).to receive(:get_move).and_return(0)
    end
  end

  def test_game
    TicTacToe::Core::Game.new_game(board).tap do |game|
      game.set_players(player, player)
    end
  end

  it "swaps the mark after every turn" do
    allow(player).to receive(:get_move).and_return(0, 1)
    expect { game.next_turn }.to change { game.current_mark }
    expect { game.next_turn }.to change { game.current_mark }
  end

  it "doesn't allow the same move to happen twice" do
    game.next_turn
    expect { game.next_turn }.to raise_error
  end

end

require 'spec_helper'

describe TicTacToe::Core::Game do

  let(:player) { mock_player }
  let(:board) { TicTacToe::Core::Board.empty_board }
  let(:game) { test_game }

  def mock_player
    instance_double("TicTacToe::Player::Human").tap do |player|
      allow(player).to receive(:set_marks)
      allow(player).to receive(:get_move).and_return(0)
    end
  end

  def test_game
    TicTacToe::Core::Game.new(board).tap do |game|
      game.reset
      game.set_players(player, player)
    end
  end

  it "swaps the mark after every turn" do
    allow(player).to receive(:get_move).and_return(0, 1)
    expect { game.next_turn }.to change { game.current_mark }
    expect { game.next_turn }.to change { game.current_mark }
  end

  it "doesn't allow the same move to happen twice" do
    game.next_turn
    expect { game.next_turn }.to raise_error
  end

end

Make the game test use new instead of new_game
Make the game test use new instead of new_game

This way the new_game constructor can not take an injected board.
Currently it's sort of confusing that new game takes a board since it
also calls reset. If only new takes an injected board though, then this
confustion will go away because new_game won't allow you to set a board
so it doesn't matter that it calls reset, and new doesn't call reset.
