From: Logan Capaldo Date: 2006-08-06T07:50:44+09:00 Subject: Re: How to redirect a string to stdin within code? On Aug 5, 2006, at 6:00 PM, Christian Seifert wrote: > Hello all, I am trying to create a unit test for a class that reads > input from stdin (ie. the user enters his name when starting the > class). I would like to write a unit test that provides the input > via a string. something like: > > input = "myname" > $stdin = input > start my class that I would like to test > > Any help is greatly appreciated. > > Christian > require 'stringio' input = StringIO.new("myname") $stdin = input