2012-10-15 59 views
0

好了,所以我在寫我的播放方法......它看起來像這樣一個規範...爲什麼RSpec的給EISDIR

 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?

回答

0

試用@ game.play.should_receive(:puts).with(@ game.drawgrid)