On 28.08.2006 00:20, Eero Saynatkari wrote: > Eero Saynatkari wrote: >> Robert Klemme wrote: >>> Eero Saynatkari wrote: >>>> It is currently not possible to substitute $stdout or >>>> $stdin with a StringIO when using the Readline library >>>> ($stderr seems to be fine) due to a T_FILE check in >>>> readline.c. >>>> >>>> Can someone come up with a reason why this might be >>>> required before I change it and submit a patch? >>>> >>>> While I am at it, I suppose I will try to provide an >>>> additional method for getting the full line of input. >>> Um, I don't understand why you would want to do that. You are talking >>> about GNU readline, aren't you? AFAIK this lib is for interactive >>> editing input - something you cannot do with a StringIO anyway. Did I >>> miss something? >> Unit-testing a program that is supposed to be >> interactive. StringIO can would be a fairly simple >> way of providing specific input and being able to >> predict the output. This is possible with files as >> well, if a bit less wieldy :) > > Come to think of it, might make such input redirection > possible in irb also (if using --readline). You can use fork with a temporary file that is used as input. Even more appropriate for testing interactive applications might be something like expect or the Ruby version of it. Kind regards robert