Class: Capybara::Server
- Inherits:
-
Object
- Object
- Capybara::Server
- Defined in:
- lib/capybara/server.rb
Defined Under Namespace
Classes: Identify
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #boot ⇒ Object
- #handler ⇒ Object
- #host ⇒ Object
-
#initialize(app) ⇒ Server
constructor
A new instance of Server.
- #responsive? ⇒ Boolean
- #url(path) ⇒ Object
Constructor Details
#initialize(app) ⇒ Server
Returns a new instance of Server.
22 23 24 |
# File 'lib/capybara/server.rb', line 22 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
20 21 22 |
# File 'lib/capybara/server.rb', line 20 def app @app end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
20 21 22 |
# File 'lib/capybara/server.rb', line 20 def port @port end |
Instance Method Details
#boot ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/capybara/server.rb', line 57 def boot return self unless @app find_available_port Capybara.log "application has already booted" and return self if responsive? Capybara.log "booting Rack applicartion on port #{port}" Thread.new do handler.run(Identify.new(@app), :Port => port, :AccessLog => []) end Capybara.log "checking if application has booted" Capybara::WaitUntil.timeout(10) do if responsive? Capybara.log("application has booted") true else sleep 0.5 false end end self rescue Timeout::Error Capybara.log "Rack application timed out during boot" exit end |
#handler ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/capybara/server.rb', line 42 def handler begin require 'rack/handler/thin' Rack::Handler::Thin rescue LoadError begin require 'rack/handler/mongrel' Rack::Handler::Mongrel rescue LoadError require 'rack/handler/webrick' Rack::Handler::WEBrick end end end |
#host ⇒ Object
26 27 28 |
# File 'lib/capybara/server.rb', line 26 def host "localhost" end |
#responsive? ⇒ Boolean
38 39 40 |
# File 'lib/capybara/server.rb', line 38 def responsive? is_running_on_port?(port) end |