spec/helpers/rspec_sem4r_helper.rb
#
# Capture $stdout and $stderr of a block
#
Capture $stdout and $stderr of a block
Capture $stdout and $stderr of a block
def capture_out
    old_stdout, old_stderr = $stdout, $stderr
    out, err = StringIO.new, StringIO.new
    $stdout, $stderr = out, err
    begin
      yield
    ensure
      $stdout, $stderr = old_stdout, old_stderr
    end
    OpenStruct.new(:out => out.string, :err => err.string)
  end
def capture_out old_stdout , old_stderr = $stdout , $stderr out , err = StringIO . new , StringIO . new $stdout , $stderr = out , err begin yield ensure $stdout , $stderr = old_stdout , old_stderr end OpenStruct . new ( :out => out . string , :err => err . string ) end
Capture $stdout and $stderr of a block
Capture $stdout and $stderr of a block