Skip to content

Commit

Permalink
Updated Specs and mocks with new method names
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeebert committed Jun 11, 2012
1 parent 1cd8962 commit 4126fda
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion spec/computer_player_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module TTT

it "should get a move from the Ai" do
@ai.move = :valid_move
@computer.get_move(@board, :player, :opponent).should == :valid_move
@computer.get_ai_move(@board, :player, :opponent).should == :valid_move
end
end
end
4 changes: 2 additions & 2 deletions spec/game_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module TTT
@game = Game.new
@board = FakeBoard.new
@game.board = @board
@game.set_board_symbols("X","O")
@game.set_game_player_symbols("X","O")
end

it "should set the player symbols" do
Expand All @@ -21,7 +21,7 @@ module TTT

it "should return the opponent's symbol" do
@game.next_player = :player1
@game.opponent.should == "O"
@game.opponent_symbol.should == "O"
end

describe "a game" do
Expand Down
27 changes: 22 additions & 5 deletions spec/limelight_game_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
require 'limelight_game'
require 'human_player'
require 'player_factory'
require 'mocks/mock_game'
require 'mocks/mock_ui'
require 'mocks/mock_board'
require 'mocks/mock_human'
require 'mocks/mock_computer'

module TTT
describe LimelightGame do
it "should have a board" do
ui = :some_ui
@game = LimelightGame.new(ui)
@game.board.should_not be_nil
before(:each) do
@ui = FakeUI.new
@game = FakeGame.new
@player_factory = TTT::PlayerFactory.new
@player1 = {type: :human, symbol: "X"}
@player2 = {type: :computer, symbol: "O"}
@limelight_game = LimelightGame.new(@ui,@player1,@player2)
@limelight_game.game = @game
@limelight_game.player_factory = @player_factory
end

it "should set up the players" do
@limelight_game.player1.class.should == TTT::HumanPlayer
@limelight_game.player2.class.should == TTT::ComputerPlayer
end
end
end
end
2 changes: 1 addition & 1 deletion spec/mocks/mock_computer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class MockComputer
attr_accessor :ai, :symbol
attr_accessor :received_move_request

def get_move(board, player, opponent)
def get_ai_move(board, player, opponent)
@received_move_request = true
end

Expand Down
4 changes: 2 additions & 2 deletions spec/mocks/mock_game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create_board(size)
@created_board = true
end

def set_board_symbols(symbol1,symbol2)
def set_game_player_symbols(symbol1,symbol2)
@board_player1_symbol = symbol1
@board_player2_symbol = symbol2
end
Expand All @@ -29,7 +29,7 @@ def current_board
return @board
end

def opponent
def opponent_symbol

end

Expand Down
2 changes: 1 addition & 1 deletion spec/mocks/mock_human.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def human?
true
end

def get_move(board)
def get_ai_move(board)
@received_move_request = true
return @move
end
Expand Down

0 comments on commit 4126fda

Please sign in to comment.