Sha256: 6ed7fe4deda0d53e7f6a89a221f0d43b5d867bfb9590d030e62150150e28707f

Contents?: true

Size: 1.08 KB

Versions: 27

Compression:

Stored size: 1.08 KB

Contents

require File.join(File.dirname(__FILE__), 'test_helper')

#if we are running from RubyMine, we need this, but it breaks things when called from Rake.
require 'minitest/autorun' unless ENV['FROM_RAKE'] == 'true'

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)
    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
    }
  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

27 entries across 27 versions & 1 rubygems

Version Path
yawast-0.7.2 test/base.rb
yawast-0.7.1 test/base.rb
yawast-0.7.0 test/base.rb
yawast-0.7.0.beta3 test/base.rb
yawast-0.7.0.beta2 test/base.rb
yawast-0.7.0.beta1 test/base.rb
yawast-0.6.0 test/base.rb
yawast-0.6.0.beta6 test/base.rb
yawast-0.6.0.beta5 test/base.rb
yawast-0.6.0.beta4 test/base.rb
yawast-0.6.0.beta3 test/base.rb
yawast-0.6.0.beta2 test/base.rb
yawast-0.6.0.beta1 test/base.rb
yawast-0.5.2 test/base.rb
yawast-0.5.1 test/base.rb
yawast-0.5.1.beta1 test/base.rb
yawast-0.5.0 test/base.rb
yawast-0.5.0.beta8 test/base.rb
yawast-0.5.0.beta7 test/base.rb
yawast-0.5.0.beta6 test/base.rb