I am testing this method:
def get_input
print "Pick a column (0-6):\n"
valid_input?(gets) || get_input
end
How can i test if the get_input
method is called from inside itself? because if i use
describe '#get_input' do
subject(:game_input) { described_class.new(1, 2) }
it 'sends get_input when input is invalid' do
allow(game_input).to receive(:valid_input?).and_return(false)
expect(game_input).to receive(:get_input)
game_input.get_input
end
it passes the test regardless since get_input
is called first anyways.
I want to test if get_input
is called from within itself, and not continue looping when i give it an invalid input in the test.
Something like:
I set valid_input? to return false in my test
I check if get_input is called on game_input, but only from inside the get_input method
Any help is appreciated
Also im completely new to RSpec so sorry for any stupid questions