lib/capybara/driver/webkit/remote_browser.rb in capybara-webkit-remote-0.0.3 vs lib/capybara/driver/webkit/remote_browser.rb in capybara-webkit-remote-0.0.4

- old
+ new

@@ -1,35 +1,42 @@ class Capybara::Driver::Webkit - class RemoteBrowser < Capybara::Driver::Webkit::Browser - attr :remote_host, :remote_port - + class RemoteConnection < Capybara::Driver::Webkit::Connection def self.open_sockets; @@_sockets ||= [ ]; end - at_exit do - socks = Capybara::Driver::Webkit::RemoteBrowser.open_sockets() + socks = Capybara::Driver::Webkit::RemoteConnection.open_sockets() while(socks.length > 0) s = socks.shift() s.close() rescue nil end end - - def initialize(hostname, port, options = { }) - @remote_host = hostname - @remote_port = port + def initialize(remote_host, remote_port, options) + @remote_host = remote_host + @remote_port = remote_port super(options) - Capybara::Driver::Webkit::RemoteBrowser.open_sockets << @socket + Capybara::Driver::Webkit::RemoteConnection.open_sockets << @socket end - - def disconnect! + def close @socket.close rescue nil - Capybara::Driver::Webkit::RemoteBrowser.open_sockets.delete(@socket) + Capybara::Driver::Webkit::RemoteConnection.open_sockets.delete(@socket) true end - def start_server ; end - def attempt_connect - @socket = @socket_class.open(remote_host, remote_port) + @socket = @socket_class.open(@remote_host, @remote_port) rescue Errno::ECONNREFUSED + end + end + + class RemoteBrowser < Capybara::Driver::Webkit::Browser + attr :remote_host, :remote_port + + def initialize(hostname, port, options = { }) + @connection = Capybara::Driver::Webkit::RemoteConnection.new(hostname, port, options) + super(@connection) + end + + def disconnect! + @connection.close rescue nil + true end end end \ No newline at end of file