spec/support/helpers.rb
# Yield to the provided block, redirecting its STDOUT
# temporarily, and return its output to our caller
#
#   msgs = with_redirected_stdout do
#     server.do_something_that_logs
#   end
#
#   puts msgs
#
Yield to the provided block, redirecting its STDOUT
temporarily, and return its output to our caller



puts msgs
Yield to the provided block redirecting its STDOUT temporarily and return its output to our caller puts msgs
def with_redirected_stdout
      ret = nil
      t = Tempfile.new("vim-channel-tests")
      begin
        old_stdout = $stdout.dup
        $stdout.reopen(t)
        $stdout.sync = true
        yield
        t.rewind
        ret = t.read
      ensure
        $stdout.reopen(old_stdout)
        t.close
      end
      ret
    end
def with_redirected_stdout ret = nil t = Tempfile . new ( "vim-channel-tests" ) begin old_stdout = $stdout . dup $stdout . reopen ( t ) $stdout . sync = true yield t . rewind ret = t . read ensure $stdout . reopen ( old_stdout ) t . close end ret end
Yield to the provided block, redirecting its STDOUT
temporarily, and return its output to our caller
Yield to the provided block redirecting its STDOUT temporarily and return its output to our caller