Have you tried StingIO
require 'stringio'
str = "hello world"
io = StringIO.new(str)
That works for the most part. If you ever have trouble getting EVERYTHING
captured that's going to $stderr, just pipe all fd[2] output to a file:
# redirect stderr
$new_stderr = File:
pen("capture_file");
$old_stderr = $stderr.clone
$stderr.reopen($new_stderr);
# ... STDERR is captured here ...
# restore stderr
$stderr.reopen($old_stderr);
$new_stderr.close
Now you have a file named "capture_file" which has everything that was sent to
stderr, even from code that didn't use Ruby's $stderr object.
Sean O'Dell