Created
September 6, 2009 00:51
-
-
Save cjohansen/181585 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def capture_stdout | |
stdout = $stdout | |
$stdout = StringIO.new | |
begin | |
yield | |
ensure | |
results = $stdout | |
$stdout = stdout | |
end | |
results | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment