Permalink
Browse files

Updated the tests to use net/http since open-uri doesn't stream respo…

…nses.

Oh, and now the tests actually pass.
  • Loading branch information...
1 parent ff7ebd5 commit 320c9469a6766bdcc1e22aef65941ca0fb901411 @technomancy technomancy committed Nov 26, 2008
Showing with 13 additions and 4 deletions.
  1. +12 −3 test/spec_rack_mongrel.rb
  2. +1 −1 test/testrequest.rb
View
@@ -6,7 +6,6 @@
require 'rack/lint'
require 'testrequest'
require 'timeout'
-require 'open-uri'
Thread.abort_on_exception = true
$tcp_defer_accept_opts = nil
@@ -165,9 +164,19 @@
end
specify "should stream #each part of the response" do
- Timeout.timeout(1) do
- open("http://#{@host}:#{@port}/stream").gets
+ body = ''
+ begin
+ Timeout.timeout(1) do
+ Net::HTTP.start(@host, @port) do |http|
+ get = Net::HTTP::Get.new('/stream')
+ http.request(get) do |response|
+ response.read_body { |part| body << part }
+ end
+ end
+ end
+ rescue Timeout::Error
end
+ body.should.not.be.empty
end
teardown do
View
@@ -51,7 +51,7 @@ def self.call(env)
def each
yield "hello there!\n"
- sleep 2
+ sleep 5
yield "that is all.\n"
end
end

0 comments on commit 320c946

Please sign in to comment.