Sha256: 240c38f5180fb9b94a34e1020a54ddd0790ea41ec8c5031f791196b56b82931d
Contents?: true
Size: 714 Bytes
Versions: 5
Compression:
Stored size: 714 Bytes
Contents
module ProcessHelper def run(args, stdin=nil) if args.kind_of?(String) args = [args] end stub_const('ARGV', args) if stdin.kind_of?(Array) stdin = stdin.join("\n") end if stdin stdin_double = double allow(stdin_double).to receive(:read).and_return(stdin) allow(stdin_double).to receive(:each_line).and_return(stdin.each_line) allow(stdin_double).to receive(:each_byte).and_return(stdin.each_byte) $stdin = stdin_double end process = Ru::Process.new process.run end def run_stream(args, stdin=nil) if args.kind_of?(String) args = [args] end args.unshift ['-s', '--stream'].sample run args, stdin end end
Version data entries
5 entries across 5 versions & 1 rubygems