1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Merge branch 'custom-server-port' of http://github.com/ichverstehe/capybara into ichverstehe-custom-server-port

Conflicts:
	spec/server_spec.rb
This commit is contained in:
Jonas Nicklas 2010-09-28 22:37:43 +02:00
commit 1afc4c6c61
3 changed files with 14 additions and 1 deletions

View file

@ -14,6 +14,7 @@ module Capybara
class << self
attr_accessor :asset_root, :app_host, :run_server, :default_host
attr_accessor :server_port
attr_accessor :default_selector, :default_wait_time, :ignore_hidden_elements
attr_accessor :save_and_open_page_path

View file

@ -73,7 +73,7 @@ module Capybara
@port = Capybara::Server.ports[@app.object_id]
if not @port or not responsive?
@port = find_available_port
@port = Capybara.server_port || find_available_port
Capybara::Server.ports[@app.object_id] = @port
Thread.new { handler.run(Identify.new(@app), :Port => @port, :AccessLog => []) }

View file

@ -17,6 +17,18 @@ describe Capybara::Server do
end.should_not raise_error
end
it "should use specified port" do
Capybara.server_port = 22789
@app = proc { |env| [200, {}, "Hello Server!"]}
@server = Capybara::Server.new(@app).boot
@res = Net::HTTP.start(@server.host, 22789) { |http| http.get('/') }
@res.body.should include('Hello Server')
Capybara.server_port = nil
end
it "should find an available port" do
@app1 = proc { |env| [200, {}, "Hello Server!"]}
@app2 = proc { |env| [200, {}, "Hello Second Server!"]}