好的,所以我正在为我的游戏方法编写一个规范......看起来像这样......
def play
#draw the board
puts drawgrid
#make a move
turn = 0
9.times do
if turn.even?
@player = @player_h.move_human("X", @board)
@move = @player.to_sym
@marker = @player_h.boardpiece
does_move_exist(@move,@marker)
is_a_human_win
else
@player = @player_c.move_computer("O", @board)
@move = @player
@marker = @player_c.boardpiece
does_move_exist(@move,@marker)
is_a_computer_win
end
puts drawgrid
turn += 1
end
end
我的规格目前看起来像这样......
describe 'play method'do
it 'draws game board to screen' do
@game.play.should_receive(:puts) == <<-EOF.gsub(/^ {6}/, '')
a | |
----------
b | |
----------
c | |
----------
1 2 3
EOF
end
end
但我得到的错误是......
1) Game class play method draws game board to screen
Failure/Error: @game.play.should_receive(:puts) == <<-EOF.gsub(/^ {6}/, '')
Errno::EISDIR:
Is a directory - spec
不知道 RSpec 告诉我什么。如何测试播放方法“放置”drawgrid?