为什么rspec给予EISDIR

时间:2012-10-15 21:28:34

标签: ruby rspec

好的,所以我正在为我的游戏方法编写一个规范......看起来像这样......

      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告诉我什么。如何测试play方法'put'drawedrid?

1 个答案:

答案 0 :(得分:0)

尝试@ game.play.should_receive(:puts).with(@ game.drawgrid)