Class: Capybara::Server

### Home Classes Methods

### In Files

- lib/capybara/server.rb

### Parent

Object

### Namespace

- CLASS Capybara::Server::Middleware

### Methods

- ::new
- ::ports
- #boot
- #error
- #reset_error!
- #responsive?

### Files

- another_test_file.txt
- test_file.txt

### Class/Module Index

Quicksearch

- Capybara
- Capybara::Ambiguous
- Capybara::CapybaraError
- Capybara::DSL
- Capybara::Driver
- Capybara::Driver::Base
- Capybara::Driver::Node
- Capybara::DriverNotFoundError
- Capybara::ElementNotFound
- Capybara::ExpectationNotMet
- Capybara::Features
- Capybara::FileNotFound
- Capybara::FrozenInTime
- Capybara::Helpers
- Capybara::InfiniteRedirectError
- Capybara::ModalNotFound
- Capybara::Node
- Capybara::Node::Actions
- Capybara::Node::Base
- Capybara::Node::Document
- Capybara::Node::DocumentMatchers
- Capybara::Node::Element
- Capybara::Node::Finders
- Capybara::Node::Matchers
- Capybara::Node::Simple
- Capybara::NotSupportedByDriverError
- Capybara::Queries
- Capybara::Queries::BaseQuery
- Capybara::Queries::TextQuery
- Capybara::Queries::TitleQuery
- Capybara::Query
- Capybara::RSpecMatchers
- Capybara::RSpecMatchers::BecomeClosed
- Capybara::RSpecMatchers::HaveSelector
- Capybara::RSpecMatchers::HaveText
- Capybara::RSpecMatchers::HaveTitle
- Capybara::RSpecMatchers::Matcher
- Capybara::RackTest
- Capybara::RackTest::Browser
- Capybara::RackTest::CSSHandlers
- Capybara::RackTest::Driver
- Capybara::RackTest::Form
- Capybara::RackTest::Form::NilUploadedFile
- Capybara::RackTest::Node
- Capybara::ReadOnlyElementError
- Capybara::Result
- Capybara::ScopeError
- Capybara::Selector
- Capybara::Selector::Filter
- Capybara::Selenium
- Capybara::Selenium::Driver
- Capybara::Selenium::Node
- Capybara::Server
- Capybara::Server::Middleware
- Capybara::Session
- Capybara::SpecHelper
- Capybara::UnselectNotAllowed
- Capybara::Window
- Capybara::WindowError
- TestApp
- TestApp::TestAppError
- Object

No matching classes.

# Capybara::Server

### Attributes

app[R]
host[R]
port[R]

### Public Class Methods

new(app, port=Capybara.server_port, host=Capybara.server_host) click to toggle source

    # File lib/capybara/server.rb, line 36
    def initialize(app, port=Capybara.server_port, host=Capybara.server_host)
      @app = app
      @middleware = Middleware.new(@app)
      @server_thread = nil # suppress warnings
      @host, @port = host, port
      @port ||= Capybara::Server.ports[@app.object_id]
      @port ||= find_available_port
    end

ports() click to toggle source

    # File lib/capybara/server.rb, line 29
    def ports
      @ports ||= {}
    end

### Public Instance Methods

boot() click to toggle source

    # File lib/capybara/server.rb, line 65
    def boot
      unless responsive?
        Capybara::Server.ports[@app.object_id] = @port

        @server_thread = Thread.new do
          Capybara.server.call(@middleware, @port)
        end

        Timeout.timeout(60) { @server_thread.join(0.1) until responsive? }
      end
    rescue Timeout::Error
      raise "Rack application timed out during boot"
    else
      self
    end

error() click to toggle source

    # File lib/capybara/server.rb, line 49
    def error
      @middleware.error
    end

reset_error!() click to toggle source

    # File lib/capybara/server.rb, line 45
    def reset_error!
      @middleware.error = nil
    end

responsive?() click to toggle source

    # File lib/capybara/server.rb, line 53
    def responsive?
      return false if @server_thread && @server_thread.join(0)

      res = Net::HTTP.start(host, @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 SystemCallError
      return false
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.