1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/net/http/test_connection.rb
shyouhei 927ca6d776 * test/net/http/test_connection.rb (TestHTTP::HTTPConnectionTest#test_connection_refused_in_request):
Wrong exception to assert.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@27958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-22 13:11:41 +00:00

33 lines
782 B
Ruby

require 'net/http'
require 'test/unit'
module TestHTTP
class HTTPConnectionTest < Test::Unit::TestCase
def test_connection_refused_in_request
bug2708 = '[ruby-core:28028]'
port = nil
localhost = "127.0.0.1"
t = Thread.new {
TCPServer.open(localhost, 0) do |serv|
_, port, _, _ = serv.addr
if clt = serv.accept
clt.close
end
end
}
begin
sleep 0.1 until port
assert_raise(EOFError, bug2708) {
n = Net::HTTP.new(localhost, port)
n.request_get('/')
}
ensure
t.join if t
end
assert_raise(Errno::ECONNREFUSED, bug2708) {
n = Net::HTTP.new(localhost, port)
n.request_get('/')
}
end
end
end