Skip to content

Instantly share code, notes, and snippets.

@cjohansen
Created September 6, 2009 00:51
Show Gist options
  • Save cjohansen/181585 to your computer and use it in GitHub Desktop.
Save cjohansen/181585 to your computer and use it in GitHub Desktop.
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