From: James Edward Gray II Date: 2006-03-24T22:56:59+09:00 Subject: Re: redirecting stdout to a String On Mar 24, 2006, at 7:50 AM, Mark Volkmann wrote: > 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 See the standard library, StringIO. James Edward Gray II