Sha256: 4b472c607cb18daf71853ad76e6c0ad5ba0aa478e0b9795069de48e0b38793c3
Contents?: true
Size: 700 Bytes
Versions: 2
Compression:
Stored size: 700 Bytes
Contents
module Capybara::Poltergeist class Server attr_reader :port, :socket, :timeout def initialize(timeout = nil) @port = find_available_port @timeout = timeout start end def timeout=(sec) @timeout = @socket.timeout = sec end def start @socket = WebSocketServer.new(port, timeout) end def restart @socket.close @socket = WebSocketServer.new(port, timeout) end def send(message) @socket.send(message) or raise DeadClient.new(message) end private 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.4.0 | lib/capybara/poltergeist/server.rb |
poltergeist-0.3.0 | lib/capybara/poltergeist/server.rb |