1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00
teamcapybara--capybara/spec/server_spec.rb
Jo Liss c444d33631 Remove broken tests for server_boot_timeout
When they were added in 09d6335, responsive? already only hit
/__identify__, which does not hit the server, but gets special-cased in
Capybara's Identify server class (and runs instantly).

So it's not clear what constitutes a "slow" server that might time out
at boot, and thus why server_boot_timeout needs to be configurable. A
server that is slow to respond to HTTP requests would not trigger the
boot timeout. All we really seem to be waiting for within the timeout
window is for Thin or WEBrick to come up.
2012-01-03 21:24:41 +01:00

74 lines
2.3 KiB
Ruby

require 'spec_helper'
describe Capybara::Server do
it "should spool up a rack server" do
@app = proc { |env| [200, {}, "Hello Server!"]}
@server = Capybara::Server.new(@app).boot
@res = Net::HTTP.start(@server.host, @server.port) { |http| http.get('/') }
@res.body.should include('Hello Server')
end
it "should do nothing when no server given" do
running do
@server = Capybara::Server.new(nil).boot
end.should_not raise_error
end
it "should bind to the specified host" do
Capybara.server_host = '0.0.0.0'
app = proc { |env| [200, {}, "Hello Server!"]}
server = Capybara::Server.new(app).boot
server.host.should == '0.0.0.0'
Capybara.server_host = nil
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!"]}
@server1 = Capybara::Server.new(@app1).boot
@server2 = Capybara::Server.new(@app2).boot
@res1 = Net::HTTP.start(@server1.host, @server1.port) { |http| http.get('/') }
@res1.body.should include('Hello Server')
@res2 = Net::HTTP.start(@server2.host, @server2.port) { |http| http.get('/') }
@res2.body.should include('Hello Second Server')
end
it "should use the server if it already running" do
@app1 = proc { |env| [200, {}, "Hello Server!"]}
@app2 = proc { |env| [200, {}, "Hello Second Server!"]}
@server1a = Capybara::Server.new(@app1).boot
@server1b = Capybara::Server.new(@app1).boot
@server2a = Capybara::Server.new(@app2).boot
@server2b = Capybara::Server.new(@app2).boot
@res1 = Net::HTTP.start(@server1b.host, @server1b.port) { |http| http.get('/') }
@res1.body.should include('Hello Server')
@res2 = Net::HTTP.start(@server2b.host, @server2b.port) { |http| http.get('/') }
@res2.body.should include('Hello Second Server')
@server1a.port.should == @server1b.port
@server2a.port.should == @server2b.port
end
end