I have the following method in class QuestionList
def ask_all
@questions.each do |question|
question.ask
@player.add_answer(gets.chomp)
end
end
The questions have integer answers, and the answers do not have to be correct for this test - there simply just needs to be an integer number received and added to the list @player.answers
with the following method in class Player
def add_answer(answer)
@answers << answer
end
How can I simulate user input to the gets.chomp
of QuestionList.ask_all
when unit testing the method as so:
class QuestionListTest < Test::Unit::TestCase
def setup
...
end
def test_ask_all
#unit test for 'QuestionList.ask_all' here
end
end