ruby-changes:41741
From: nobu <ko1@a...>
Date: Sat, 13 Feb 2016 16:52:08 +0900 (JST)
Subject: [ruby-changes:41741] nobu:r53815 (trunk): test/uri/test_generic.rb: split test_find_proxy
nobu 2016-02-13 16:52:25 +0900 (Sat, 13 Feb 2016) New Revision: 53815 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53815 Log: test/uri/test_generic.rb: split test_find_proxy Modified files: trunk/test/uri/test_generic.rb Index: test/uri/test_generic.rb =================================================================== --- test/uri/test_generic.rb (revision 53814) +++ test/uri/test_generic.rb (revision 53815) @@ -795,12 +795,18 @@ class URI::TestGeneric < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/uri/test_generic.rb#L795 # 192.0.2.0/24 is TEST-NET. [RFC3330] - def test_find_proxy + def test_find_proxy_bad_uri assert_raise(URI::BadURIError){ URI("foo").find_proxy } + end + + def test_find_proxy_no_env with_env({}) { assert_nil(URI("http://192.0.2.1/").find_proxy) assert_nil(URI("ftp://192.0.2.1/").find_proxy) } + end + + def test_find_proxy with_env('http_proxy'=>'http://127.0.0.1:8080') { assert_equal(URI('http://127.0.0.1:8080'), URI("http://192.0.2.1/").find_proxy) assert_nil(URI("ftp://192.0.2.1/").find_proxy) @@ -809,16 +815,29 @@ class URI::TestGeneric < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/uri/test_generic.rb#L815 assert_nil(URI("http://192.0.2.1/").find_proxy) assert_equal(URI('http://127.0.0.1:8080'), URI("ftp://192.0.2.1/").find_proxy) } + end + + def test_find_proxy_get with_env('REQUEST_METHOD'=>'GET') { assert_nil(URI("http://192.0.2.1/").find_proxy) } with_env('CGI_HTTP_PROXY'=>'http://127.0.0.1:8080', 'REQUEST_METHOD'=>'GET') { assert_equal(URI('http://127.0.0.1:8080'), URI("http://192.0.2.1/").find_proxy) } + end + + def test_find_proxy_no_proxy with_env('http_proxy'=>'http://127.0.0.1:8080', 'no_proxy'=>'192.0.2.2') { assert_equal(URI('http://127.0.0.1:8080'), URI("http://192.0.2.1/").find_proxy) assert_nil(URI("http://192.0.2.2/").find_proxy) } + with_env('http_proxy'=>'http://127.0.0.1:8080', 'no_proxy'=>'example.org') { + assert_nil(URI("http://example.org/").find_proxy) + assert_nil(URI("http://www.example.org/").find_proxy) + } + end + + def test_find_proxy_bad_value with_env('http_proxy'=>'') { assert_nil(URI("http://192.0.2.1/").find_proxy) assert_nil(URI("ftp://192.0.2.1/").find_proxy) @@ -827,10 +846,6 @@ class URI::TestGeneric < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/uri/test_generic.rb#L846 assert_nil(URI("http://192.0.2.1/").find_proxy) assert_nil(URI("ftp://192.0.2.1/").find_proxy) } - with_env('http_proxy'=>'http://127.0.0.1:8080', 'no_proxy'=>'example.net') { - assert_nil(URI("http://example.net/").find_proxy) - assert_nil(URI("http://www.example.net/").find_proxy) - } end def test_find_proxy_case_sensitive_env -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/