Sha256: 452e48705ee9d04f87d81ef966d3fc74da5b0b2d6dfdf53ff6b3cbd889adc0fd

Contents?: true

Size: 914 Bytes

Versions: 12

Compression:

Stored size: 914 Bytes

Contents

module TestBase
  def override_stdout
    @orig_stdout = $stdout
    reset_stdout
  end

  def stdout_value
    $stdout.string
  end

  def reset_stdout
    $stdout = StringIO.new
  end

  def restore_stdout
    $stdout = @orig_stdout
  end

  def start_web_server(file, url, port = 1234)
    thr = Thread.new {
      server = WEBrick::HTTPServer.new :Port => port,
                                       :BindAddress => 'localhost',
                                       :AccessLog => [],
                                       :Logger => WEBrick::Log.new('/dev/null')
      server.mount "/#{url}", WEBrick::HTTPServlet::FileHandler, file
      server.start
    }

    thr
  end

  def parse_headers_from_file(file)
    headers = {}
    File.foreach(file) do |line|
      key = line.partition(':').first.trim
      value = line.partition(':').last.trim

      headers[key] = value
    end

    headers
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
yawast-0.4.0.beta4 test/base.rb
yawast-0.4.0.beta3 test/base.rb
yawast-0.4.0.beta2 test/base.rb
yawast-0.4.0.beta1 test/base.rb
yawast-0.3.0 test/base.rb
yawast-0.3.0.beta2 test/base.rb
yawast-0.3.0.beta1 test/base.rb
yawast-0.2.2 test/base.rb
yawast-0.2.1 test/base.rb
yawast-0.2.0.beta3 test/base.rb
yawast-0.2.0.beta2 test/base.rb
yawast-0.2.0.beta1 test/base.rb