Skip to content
This repository has been archived by the owner on Nov 27, 2020. It is now read-only.

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
arturocastro committed Apr 2, 2017
1 parent ad3ba97 commit c9ac701
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -280,9 +280,8 @@ end
to be passed to PhantomJS, e.g. `['--load-images=no', '--ignore-ssl-errors=yes']`
* `:extensions` (Array) - An array of JS files to be preloaded into
the phantomjs browser. Useful for faking unsupported APIs.
* `:port` (Fixnum) - The port which should be used to communicate
* `:port` (Fixnum) - The port which should be used to communicate with the PhantomJS process. Defaults to a random open port.
* `:host` (String) - The name or IP of the PhantomJS host. Default is '127.0.0.1'.
with the PhantomJS process. Defaults to a random open port.
* `:url_blacklist` (Array) - Default session url blacklist - expressed as an array of strings to match against requested URLs.
* `:url_whitelist` (Array) - Default session url whitelist - expressed as an array of strings to match against requested URLs.

Expand Down
7 changes: 2 additions & 5 deletions lib/capybara/poltergeist/client/compiled/connection.js
Expand Up @@ -4,12 +4,9 @@ Poltergeist.Connection = (function() {
function Connection(owner, port, host) {
this.owner = owner;
this.port = port;
this.host = host;
this.host = host != null ? host : "127.0.0.1";
this.commandReceived = bind(this.commandReceived, this);
if (this.host == null) {
this.host = "127.0.0.1";
}
this.socket = new WebSocket("ws://127.0.0.1:" + this.port + "/");
this.socket = new WebSocket("ws://" + this.host + ":" + this.port + "/");
this.socket.onmessage = this.commandReceived;
this.socket.onclose = function() {
return phantom.exit();
Expand Down
7 changes: 2 additions & 5 deletions lib/capybara/poltergeist/client/connection.coffee
@@ -1,9 +1,6 @@
class Poltergeist.Connection
constructor: (@owner, @port, @host) ->
#@socket = new WebSocket "ws://#{@host}:#{@port}/"
if !@host?
@host = "127.0.0.1"
@socket = new WebSocket "ws://127.0.0.1:#{@port}/"
constructor: (@owner, @port, @host = "127.0.0.1") ->
@socket = new WebSocket "ws://#{@host}:#{@port}/"
@socket.onmessage = this.commandReceived
@socket.onclose = -> phantom.exit()

Expand Down
15 changes: 8 additions & 7 deletions spec/integration/driver_spec.rb
Expand Up @@ -865,15 +865,16 @@ def create_screenshot(file, *args)
# Use custom host "pointing" to localhost, specified by POLTERGEIST_TEST_HOST env var.
# Use /etc/hosts or iptables for this: https://superuser.com/questions/516208/how-to-change-ip-address-to-point-to-localhost
# A custom host and corresponding env var for Travis is specified in .travis.yml
# If var is unspecified, use localhost
env_var = ENV['POLTERGEISt_TEST_HOST']
host = env_var.nil? ? env_var : 'localhost'
driver = Capybara::Poltergeist::Driver.new(@driver.app, host: host, port: 12345)
driver.visit session_url('/')
# If var is unspecified, skip test
host = ENV['POLTERGEIST_TEST_HOST']
if not host.nil?
driver = Capybara::Poltergeist::Driver.new(@driver.app, host: host, port: 12345)
driver.visit session_url('/')

expect { TCPServer.new(host, 12345) }.to raise_error(Errno::EADDRINUSE)
expect { TCPServer.new(host, 12345) }.to raise_error(Errno::EADDRINUSE)
end
ensure
driver.quit
driver.quit if driver
end
end

Expand Down

0 comments on commit c9ac701

Please sign in to comment.