Removes specs not directly related to the patch

This commit is contained in:
John Wilger 2013-03-17 16:35:48 -07:00
parent 583c54cef5
commit 04413c21e5
2 changed files with 7 additions and 51 deletions

View File

@ -55,7 +55,7 @@ module Capybara
end
def responsive?
return false if server_thread && server_thread.join(0)
return false if @server_thread && @server_thread.join(0)
res = Net::HTTP.start(host, @port) { |http| http.get('/__identify__') }
@ -74,7 +74,7 @@ module Capybara
Capybara.server.call(@middleware, @port)
end
Timeout.timeout(60) { server_thread.join(0.1) until responsive? }
Timeout.timeout(60) { @server_thread.join(0.1) until responsive? }
end
rescue Timeout::Error
raise "Rack application timed out during boot"
@ -84,8 +84,6 @@ module Capybara
private
attr_reader :server_thread
def find_available_port
server = TCPServer.new('127.0.0.1', 0)
server.addr[1]

View File

@ -99,52 +99,10 @@ describe Capybara::Server do
end
end
context "#responsive?" do
let(:app) { lambda { [200, {}, ['hello']] } }
let(:server_thread) { stub('Server Thread', :join => false) }
let(:subject) {
Capybara::Server.new(app).tap do |server|
server.stub!(:server_thread => server_thread)
end
}
let(:http_response) {
stub('HTTP Response', :is_a? => false)
}
before(:each) do
Net::HTTP.stub!(:start => http_response)
end
it "returns false if the server thread is present but no longer running" do
server_thread.should_receive(:join).with(0).and_return(true)
expect(subject.responsive?).to eq false
end
shared_examples_for "it receives an HTTP response" do |response_class|
context "when the Net::HTTP response is #{response_class}" do
before(:each) do
http_response.should_receive(:is_a?).with(response_class).and_return(true)
end
it "returns true when the Net::HTTP response body is equal to the application's #object_id" do
http_response.stub!(:body => app.object_id.to_s)
expect(subject.responsive?).to eq true
end
it "returns false when the Net::HTTP response body is not equal to the application's #object_id" do
http_response.stub!(:body => "Incorrect")
expect(subject.responsive?).to eq false
end
end
end
it_behaves_like "it receives an HTTP response", Net::HTTPSuccess
it_behaves_like "it receives an HTTP response", Net::HTTPRedirection
it "returns false when the Net::HTTP calls raise a SystemCallError" do
Net::HTTP.should_receive(:start).and_raise(SystemCallError.allocate)
expect(subject.responsive?).to eq false
end
it "is not #responsive? when Net::HTTP raises a SystemCallError" do
app = lambda { [200, {}, ['Hello, world']] }
server = Capybara::Server.new(app)
Net::HTTP.should_receive(:start).and_raise(SystemCallError.allocate)
expect(server.responsive?).to eq false
end
end