Sha256: d8c9e70ed16757e03966f6292018df79e503a113ff39639df397ca176cda8bb4
Contents?: true
Size: 688 Bytes
Versions: 8
Compression:
Stored size: 688 Bytes
Contents
# encoding: utf-8 require 'stringio' class Cri::TestCase < MiniTest::Unit::TestCase def setup @orig_io = capture_io end def teardown uncapture_io(*@orig_io) end def capture_io_while(&block) orig_io = capture_io block.call [ $stdout.string, $stderr.string ] ensure uncapture_io(*orig_io) end def lines(string) string.scan(/^.*\n/).map { |s| s.chomp } end private def capture_io orig_stdout = $stdout orig_stderr = $stderr $stdout = StringIO.new $stderr = StringIO.new [ orig_stdout, orig_stderr ] end def uncapture_io(orig_stdout, orig_stderr) $stdout = orig_stdout $stderr = orig_stderr end end
Version data entries
8 entries across 8 versions & 1 rubygems