Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removes specs not directly related to the patch

  • Loading branch information...
commit 04413c21e514032822a4310c88517ad7c3e396db 1 parent 583c54c
@jwilger jwilger authored
Showing with 7 additions and 51 deletions.
  1. +2 −4 lib/capybara/server.rb
  2. +5 −47 spec/server_spec.rb
View
6 lib/capybara/server.rb
@@ -55,7 +55,7 @@ def host
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 @@ def boot
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 @@ def boot
private
- attr_reader :server_thread
-
def find_available_port
server = TCPServer.new('127.0.0.1', 0)
server.addr[1]
View
52 spec/server_spec.rb
@@ -99,52 +99,10 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.