title: rspec test if method is called
body: <p>I can't figure out how to write a test that will work, that also doesn't run anything in my script in the CL. When @counter is 9, it is supposed to trigger #tie_game? but it does not work. @counter is initialized to 0 and is incremented by one every time a player puts an X or an O on the game board. How can I test that once @counter is 9 that it calls tie_game? and that when it is less than 9 it will not?</p>
  
  <pre><code>def initialize(player1, player2)
      @player1 = player1
      @player2 = player2
      @rows = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
  
      @wins = [1, 2, 3], [4, 5, 6], [7, 8, 9], 
          [1, 4, 7], [2, 5, 8], [3, 6, 9],
          [1, 5, 9], [3, 5, 7]
  
      @selected_numbers = []
      @counter = 0
  end
  
  def increment_counter
      @counter += 1
  
      if @counter == 9
          tie_game?
      end
  end
  
  def tie_game?
      puts "The game was a tie. Nicely played #{@player1} &amp; #{@player2}!"
      play_again  
  end
  </code></pre>
  
  <p>I tried this: Can you explain why it does not work though?</p>
  
  <pre><code>describe "increment_counter" do
      context "counter equals 9" do
          it "calls tie_game?" do
              game.instance_variable_set(:@counter, 9)
              allow(game).to receive(:increment_counter)
              #expect(STDOUT).to receive(:puts).with("The game was a tie. Nicely played #{@player1} &amp; #{@player2}!")
              expect(game).to receive(:tie_game?)
          end
      end
      context "counter is less than 9" do
          it "does not call tie_game?" do
              game.instance_variable_set(:@counter, 4)
              game.increment_counter
              expect(game).not_to receive(:tie_game?)  
          end
      end
  end
  </code></pre>