mirror of
https://github.com/teampoltergeist/poltergeist.git
synced 2022-11-09 12:05:00 -05:00
Fix setting of fixed port
This commit is contained in:
parent
98d4a4a893
commit
467c9b9ea0
3 changed files with 15 additions and 5 deletions
|
@ -2,7 +2,7 @@ module Capybara::Poltergeist
|
||||||
class Server
|
class Server
|
||||||
attr_reader :socket, :fixed_port, :timeout
|
attr_reader :socket, :fixed_port, :timeout
|
||||||
|
|
||||||
def initialize(port = nil, timeout = nil)
|
def initialize(fixed_port = nil, timeout = nil)
|
||||||
@fixed_port = fixed_port
|
@fixed_port = fixed_port
|
||||||
@timeout = timeout
|
@timeout = timeout
|
||||||
start
|
start
|
||||||
|
|
|
@ -24,7 +24,7 @@ module Capybara::Poltergeist
|
||||||
|
|
||||||
FileUtils.rm_f file
|
FileUtils.rm_f file
|
||||||
|
|
||||||
driver = Capybara::Poltergeist::Driver.new(nil, :phantomjs => path, :port => 44679)
|
driver = Capybara::Poltergeist::Driver.new(nil, :phantomjs => path)
|
||||||
driver.browser
|
driver.browser
|
||||||
|
|
||||||
# If the correct custom path is called, it will touch the file. We allow at
|
# If the correct custom path is called, it will touch the file. We allow at
|
||||||
|
@ -80,8 +80,7 @@ module Capybara::Poltergeist
|
||||||
Capybara::Poltergeist::Driver.new(
|
Capybara::Poltergeist::Driver.new(
|
||||||
app,
|
app,
|
||||||
:logger => TestSessions.logger,
|
:logger => TestSessions.logger,
|
||||||
:window_size => [800, 600],
|
:window_size => [800, 600]
|
||||||
:port => 44679
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
driver = Capybara::Session.new(:poltergeist_with_custom_window_size, TestApp).driver
|
driver = Capybara::Session.new(:poltergeist_with_custom_window_size, TestApp).driver
|
||||||
|
@ -185,7 +184,7 @@ module Capybara::Poltergeist
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'supports quitting the session' do
|
it 'supports quitting the session' do
|
||||||
driver = Capybara::Poltergeist::Driver.new(nil, :port => 44679)
|
driver = Capybara::Poltergeist::Driver.new(nil)
|
||||||
pid = driver.client_pid
|
pid = driver.client_pid
|
||||||
|
|
||||||
Process.kill(0, pid).should == 1
|
Process.kill(0, pid).should == 1
|
||||||
|
@ -398,5 +397,16 @@ module Capybara::Poltergeist
|
||||||
@driver.cookies['foo'].expires.should == time
|
@driver.cookies['foo'].expires.should == time
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "allows the driver to have a fixed port" do
|
||||||
|
begin
|
||||||
|
driver = Capybara::Poltergeist::Driver.new(@driver.app, port: 12345)
|
||||||
|
driver.visit session_url('/')
|
||||||
|
|
||||||
|
expect { TCPServer.new("127.0.0.1", 12345) }.to raise_error(Errno::EADDRINUSE)
|
||||||
|
ensure
|
||||||
|
driver.quit
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
0
spec/unit/server_spec.rb
Normal file
0
spec/unit/server_spec.rb
Normal file
Loading…
Add table
Reference in a new issue