Sha256: ce4b7e452a0dc99774fa75dde7cd9dbe3469fa08089beffd054a13691f06b19e

Contents?: true

Size: 537 Bytes

Versions: 1

Compression:

Stored size: 537 Bytes

Contents

require 'rack/handler/thin'
require 'net/http'

class Server
  # Got it from Capybara, but simplified it a bit.
  # lib/capybara/server.rb
  def responsive?
    res = Net::HTTP.start('localhost', 9595) { |http| http.get('/') }

    res.is_a?(Net::HTTPSuccess) or res.is_a?(Net::HTTPRedirection)
  rescue Errno::ECONNREFUSED, Errno::EBADF
    return false
  end

  def boot(app)
    if not responsive?
      Thread.new do
        Thin::Logging.silent = true
        Rack::Handler::Thin.run(app, :Port => 9595)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outpost-0.2.0 test/support/server.rb