Sha256: 46fec099bb794a730a163932a6e856b6d76c584ab3002bed648daa46037964f7

Contents?: true

Size: 555 Bytes

Versions: 2

Compression:

Stored size: 555 Bytes

Contents

module Capybara::Poltergeist
  class Server
    attr_reader :port

    def initialize
      @port = find_available_port
      start
    end

    def start
      server_manager.start(port)
    end

    def restart
      server_manager.restart(port)
    end

    def send(message)
      server_manager.send(port, message)
    end

    private

    def server_manager
      ServerManager.instance
    end

    def find_available_port
      server = TCPServer.new('127.0.0.1', 0)
      server.addr[1]
    ensure
      server.close if server
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
poltergeist-0.2.0 lib/capybara/poltergeist/server.rb
poltergeist-0.1.0 lib/capybara/poltergeist/server.rb