Sha256: 85726e47c4202b6ce1cdd9dc925ec52eca36ee1bf0dccf92c13119edaae4f224
Contents?: true
Size: 729 Bytes
Versions: 9
Compression:
Stored size: 729 Bytes
Contents
module Gorillib module TestHelpers module_function def dummy_stdio(stdin_text=nil) stdin = stdin_text.nil? ? $stdin : StringIO.new(stdin_text) new_fhs = [stdin, StringIO.new('', 'w'), StringIO.new('', 'w')] old_fhs = [$stdin, $stdout, $stderr] begin $stdin, $stdout, $stderr = new_fhs yield ensure $stdin, $stdout, $stderr = old_fhs end new_fhs[1..2] end # # Temporarily sets the global variables $stderr and $stdout to a capturable StringIO; # restores them at the end, even if there is an error # def capture_output dummy_stdio{ yield } end alias_method :quiet_output, :capture_output end end
Version data entries
9 entries across 9 versions & 2 rubygems