From: Mark Volkmann Date: 2006-03-24T22:50:42+09:00 Subject: redirecting stdout to a String I wrote a unit test for a method that writes to stdout. I got it to work, but I'm not sure my approach was the best. Is there a more recommended way to do this? # Create a String with a singleton write method # that allows it to take the place of stdout. actual = ''' def actual.write(data); self << data; end old_stdout, $stdout = $stdout, actual # Invoke method to test that writes to stdout. $stdout = old_stdout # restore stdout -- R. Mark Volkmann Object Computing, Inc.