次のような gets.chomp を使用した単純な関数があります。
def welcome_user
puts "Welcome! What would you like to do?"
action = gets.chomp
end
ruby次のような組み込みTestCaseスイートを使用してテストしたいと思います。
class ViewTest < Test::Unit::TestCase
def test_welcome
welcome_user
end
end
問題は、そのテストを実行するとgets.chomp、ユーザーが何かを入力する必要があるため、テストが停止することです。を使用してユーザー入力をシミュレートする方法はありrubyますか?