diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-13 05:16:37 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-13 05:16:37 +0000 |
commit | b4089826fba2d261f7857307be50aeeb0b8adfce (patch) | |
tree | 1a123596fb7f0e44eaf77d4211a9537dc6ab8a44 /test | |
parent | b13432890fba7b2aac294710d67d1f96e2d7eabe (diff) | |
download | ruby-b4089826fba2d261f7857307be50aeeb0b8adfce.tar.gz |
test_http.rb: test without DNS access
* test/net/http/test_http.rb: get rid of accessing DNS actually
for some servers returning wrong results.
[ruby-core:67454] [Bug #10721]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/net/http/test_http.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index 4d82fd7d1e..b72aadd54c 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -189,11 +189,14 @@ class TestNetHTTP < Test::Unit::TestCase end def test_failure_message_includes_failed_domain_and_port - begin - Net::HTTP.get(URI.parse("http://doesnotexist.bogus")) - fail "should have raised" - rescue => e - assert_includes e.message, "doesnotexist.bogus:80" + # hostname to be included in the error message + host = Struct.new(:to_s).new("<example>") + port = 2119 + # hack to let TCPSocket.open fail + def host.to_str; raise SocketError, "open failure"; end + uri = Struct.new(:scheme, :hostname, :port).new("http", host, port) + assert_raise_with_message(SocketError, /#{host}:#{port}/) do + Net::HTTP.get(uri) end end |