class Capybara::Poltergeist::Server
Attributes
custom_host[R]
fixed_port[R]
socket[R]
timeout[R]
Public Class Methods
new(fixed_port = nil, timeout = nil, custom_host = nil)
click to toggle source
# File lib/capybara/poltergeist/server.rb, line 6 def initialize(fixed_port = nil, timeout = nil, custom_host = nil) @fixed_port = fixed_port @timeout = timeout @custom_host = custom_host start end
Public Instance Methods
host()
click to toggle source
# File lib/capybara/poltergeist/server.rb, line 17 def host @socket.host end
port()
click to toggle source
# File lib/capybara/poltergeist/server.rb, line 13 def port @socket.port end
restart()
click to toggle source
# File lib/capybara/poltergeist/server.rb, line 33 def restart stop start end
send(command)
click to toggle source
# File lib/capybara/poltergeist/server.rb, line 38 def send(command) receive_timeout = nil # default if command.name == 'visit' command.args.push(timeout) # set the client set visit timeout parameter receive_timeout = timeout + 5 # Add a couple of seconds to let the client timeout first end @socket.send(command.id, command.message, receive_timeout) or raise DeadClient.new(command.message) end
start()
click to toggle source
# File lib/capybara/poltergeist/server.rb, line 25 def start @socket = WebSocketServer.new(fixed_port, timeout, custom_host) end
stop()
click to toggle source
# File lib/capybara/poltergeist/server.rb, line 29 def stop @socket.close end
timeout=(sec)
click to toggle source
# File lib/capybara/poltergeist/server.rb, line 21 def timeout=(sec) @timeout = @socket.timeout = sec end