Sha256: e29842ad736a7e516974904b8cf1f1b695812d5987713b90c50aa72285be4ec1
Contents?: true
Size: 724 Bytes
Versions: 1
Compression:
Stored size: 724 Bytes
Contents
require 'tempfile' module IOCapture def with_io file = Tempfile.new('scripted-test-log') yield file file.rewind file.read ensure file.close! file.unlink end def with_io read, write = IO.pipe text = "" thread = Thread.new do read.each_char do |char| text << char end end yield write read.sync sleep 0.01 thread.terminate text end def capture stdout = StringIO.new stderr = StringIO.new $stdout = stdout $stderr = stderr yield stdout.rewind stderr.rewind [ stdout, stderr ] ensure $stdout = STDOUT $stderr = STDERR end end RSpec.configure do |config| config.include IOCapture end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
scripted-0.0.1 | spec/support/io_capture.rb |