I have this method for a tic tac tow game:
def start(token)
if token == "X"
puts "#{@player1}: Please enter a number for your X to go"
elsif token == "O"
puts "#{@player2}: Please enter a number for your O to go"
end
player_input = STDIN.gets.chomp
locate_player_input(token, player_input)
end
I'm only trying to test to see if the correct thing is puts'd to the terminal. I have this test:
describe "#start" do
context "X player's turns" do
it "prints proper messege" do
expect(STDOUT).to receive(:puts).with("Harry: Please enter a number for your X to go")
game.start("X")
end
end
end
But I have a feeling the game.start("X") line is what is not making this work. How can I write the test to just check if the puts statement is correctly outputted?
if
,else
, just useputs "#{@player2}: Please enter a number for your #{token} to go"
. – lwassink