From: Massimiliano Mirra [mailto:list@NOSPAMchromatic-harp.com]
I don’t see any obvious assertion in Test::Unit that allows
checking of I/O to $stdout/$stderr. What’s a good way to
test for such a case?Get stringio.rb from www.allruby.com/rpkg/stringio.rb
Massimiliano –
Thanks for the suggestion! I have installed stringio.rb but am having
problems with the redir method. I get ‘uninitialized stream’ errors in both
my code and your unit tests, on many flavors of Ruby (windows/linux, 1.6.5
through 1.7.2):
% ruby-latest -v /users/jgray/pkgs/ruby/lib/stringio.rb
ruby 1.7.2 (2002-06-04) [i686-linux]
Loaded suite /users/jgray/pkgs/ruby/lib/stringio
Started…
…
Error occurred in test_redirect(TestStringIO): IOError: uninitialized stream
/users/jgray/pkgs/ruby/lib/stringio.rb:133:in redir' /users/jgray/pkgs/ruby/lib/stringio.rb:151:in test_redirect’
/users/jgray/pkgs/ruby/lib/stringio.rb:265
…
Finished in 0.04797999999999999 seconds.
16 runs, 25 assertions, 0 failures, 1 errors
The context in stringio.rb:
131 begin
132 $defout, $stderr = redout, rederr
=> 133 $stdout = redout
134 yield
135 ensure
Any ideas what might be happening?
Thanks,
- jeff