Sha256: 3f2f2d2b357c0e5b373c08f8023f6587d924ff3bfda780084c7358d9e2e3f4ec
Contents?: true
Size: 1.64 KB
Versions: 2
Compression:
Stored size: 1.64 KB
Contents
require 'rspec/core' require 'uri' require 'net/http' module WatirWebdriverRails class Identify def initialize(app) @app = app end def call(env) if env["PATH_INFO"] == "/__identify__" [200, {}, [@app.object_id.to_s]] else @app.call(env) end end end class << self attr_accessor :host, :port, :server_boot_timeout, :app def run_server @app = Rack::Builder.new { map "/" do if Rails.version.to_f >= 3.0 run Rails.application else # Rails 2 use Rails::Rack::Static run ActionController::Dispatcher.new end end }.to_app Thread.new do begin require 'rack/handler/thin' Thin::Logging.silent = true Rack::Handler::Thin.run(Identify.new(app), :Port => @port) rescue LoadError require 'rack/handler/webrick' Rack::Handler::WEBrick.run(Identify.new(app), :Port => @port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0)) end end timeout(@server_boot_timeout) do if responsive? true else sleep(0.5) false end end end def responsive? res = Net::HTTP.start("127.0.0.1", @port) { |http| http.get('/__identify__') } if res.is_a?(Net::HTTPSuccess) or res.is_a?(Net::HTTPRedirection) return res.body == @app.object_id.to_s end rescue Errno::ECONNREFUSED, Errno::EBADF return false end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
watir-webdriver-rails-0.0.2 | lib/watir-webdriver-rails/rails.rb |
watir-webdriver-rails-0.0.1 | lib/watir-webdriver-rails/rails.rb |