Sha256: ff91841ab3d94df0f3cf233b5a35ce855cb1b4e7ced66ec2274e3bb6d0b39b9f
Contents?: true
Size: 1.13 KB
Versions: 6
Compression:
Stored size: 1.13 KB
Contents
# encoding: utf-8 require 'fedux_org_stdlib/environment' module ProxyTester module SpecHelper module Environment include FeduxOrgStdlib::Environment private def set_stdin(obj) $stdin = obj end def set_stderr(obj) $stderr = obj end def set_stdout(obj) $stdout = obj end def get_stdin $stdin end def get_stderr $stderr end def get_stdout $stdout end public def mock_io(io, *args, &block) raise RuntimeError, "Unsupported io: #{io}, allowed: stderr, stdin, stdout" unless [:stderr, :stdout, :stdin].include? io old_io = send("get_#{io}") io_obj = send("set_#{io}", StringIO.new) io_obj.puts(args.shift) until args.blank? io_obj.rewind block.call ensure io_obj = send("set_#{io}", old_io) end end end end RSpec.configure do |c| c.include ProxyTester::SpecHelper::Environment c.before(:suite) do %w{ http_proxy https_proxy HTTP_PROXY HTTPS_PROXY }.each { |var| ENV.delete(var) } end end
Version data entries
6 entries across 6 versions & 1 rubygems