diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-18 21:29:41 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-18 21:29:41 +0000 |
commit | 95683e5cb2d1ab8351402b09ef853dcdf875bf8d (patch) | |
tree | 44500dba22e9aa94ecc5d4fd348512d0fb236501 /test/rubygems/test_gem_request.rb | |
parent | 81629f05312cc4df2193a17f13c581eda174d9af (diff) | |
download | ruby-95683e5cb2d1ab8351402b09ef853dcdf875bf8d.tar.gz |
* lib/rubygems: Update to RubyGems 2.2.0.preview.1
This brings several new features to RubyGems summarized here:
https://github.com/rubygems/rubygems/blob/v2.2.0.preview.1/History.txt
* test/rubygems: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_request.rb')
-rw-r--r-- | test/rubygems/test_gem_request.rb | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/test/rubygems/test_gem_request.rb b/test/rubygems/test_gem_request.rb index 869c6730a9..f8b9a90897 100644 --- a/test/rubygems/test_gem_request.rb +++ b/test/rubygems/test_gem_request.rb @@ -12,8 +12,9 @@ class TestGemRequest < Gem::TestCase super @proxy_uri = "http://localhost:1234" + @uri = URI('http://example') - @request = Gem::Request.new nil, nil, nil, nil + @request = Gem::Request.new @uri, nil, nil, nil end def teardown @@ -25,7 +26,7 @@ class TestGemRequest < Gem::TestCase def test_initialize_proxy proxy_uri = 'http://proxy.example.com' - request = Gem::Request.new nil, nil, nil, proxy_uri + request = Gem::Request.new @uri, nil, nil, proxy_uri assert_equal proxy_uri, request.proxy_uri.to_s end @@ -33,7 +34,7 @@ class TestGemRequest < Gem::TestCase def test_initialize_proxy_URI proxy_uri = 'http://proxy.example.com' - request = Gem::Request.new nil, nil, nil, URI(proxy_uri) + request = Gem::Request.new @uri, nil, nil, URI(proxy_uri) assert_equal proxy_uri, request.proxy_uri.to_s end @@ -43,7 +44,7 @@ class TestGemRequest < Gem::TestCase ENV['http_proxy_user'] = 'foo' ENV['http_proxy_pass'] = 'bar' - request = Gem::Request.new nil, nil, nil, nil + request = Gem::Request.new @uri, nil, nil, nil proxy = request.proxy_uri @@ -51,6 +52,32 @@ class TestGemRequest < Gem::TestCase assert_equal 'bar', proxy.password end + def test_initialize_proxy_ENV_https + ENV['https_proxy'] = @proxy_uri + + request = Gem::Request.new URI('https://example'), nil, nil, nil + + proxy = request.proxy_uri + + assert_equal URI(@proxy_uri), proxy + end + + def test_get_proxy_from_env_fallback + ENV['http_proxy'] = @proxy_uri + + proxy = @request.get_proxy_from_env 'https' + + assert_equal URI(@proxy_uri), proxy + end + + def test_get_proxy_from_env_https + ENV['https_proxy'] = @proxy_uri + + proxy = @request.get_proxy_from_env 'https' + + assert_equal URI(@proxy_uri), proxy + end + def test_get_proxy_from_env_domain ENV['http_proxy'] = @proxy_uri ENV['http_proxy_user'] = 'foo\user' @@ -112,7 +139,7 @@ class TestGemRequest < Gem::TestCase end def test_user_agent - ua = Gem::Request.new(nil, nil, nil, nil).user_agent + ua = Gem::Request.new(@uri, nil, nil, nil).user_agent assert_match %r%^RubyGems/\S+ \S+ Ruby/\S+ \(.*?\)%, ua assert_match %r%RubyGems/#{Regexp.escape Gem::VERSION}%, ua @@ -127,7 +154,7 @@ class TestGemRequest < Gem::TestCase Object.send :remove_const, :RUBY_ENGINE if defined?(RUBY_ENGINE) Object.send :const_set, :RUBY_ENGINE, 'vroom' - ua = Gem::Request.new(nil, nil, nil, nil).user_agent + ua = Gem::Request.new(@uri, nil, nil, nil).user_agent assert_match %r%\) vroom%, ua ensure @@ -140,7 +167,7 @@ class TestGemRequest < Gem::TestCase Object.send :remove_const, :RUBY_ENGINE if defined?(RUBY_ENGINE) Object.send :const_set, :RUBY_ENGINE, 'ruby' - ua = Gem::Request.new(nil, nil, nil, nil).user_agent + ua = Gem::Request.new(@uri, nil, nil, nil).user_agent assert_match %r%\)%, ua ensure @@ -153,7 +180,7 @@ class TestGemRequest < Gem::TestCase Object.send :remove_const, :RUBY_PATCHLEVEL Object.send :const_set, :RUBY_PATCHLEVEL, 5 - ua = Gem::Request.new(nil, nil, nil, nil).user_agent + ua = Gem::Request.new(@uri, nil, nil, nil).user_agent assert_match %r% patchlevel 5\)%, ua ensure @@ -168,7 +195,7 @@ class TestGemRequest < Gem::TestCase Object.send :remove_const, :RUBY_REVISION if defined?(RUBY_REVISION) Object.send :const_set, :RUBY_REVISION, 6 - ua = Gem::Request.new(nil, nil, nil, nil).user_agent + ua = Gem::Request.new(@uri, nil, nil, nil).user_agent assert_match %r% revision 6\)%, ua assert_match %r%Ruby/#{Regexp.escape RUBY_VERSION}dev%, ua @@ -183,7 +210,7 @@ class TestGemRequest < Gem::TestCase Object.send :const_set, :RUBY_PATCHLEVEL, -1 Object.send :remove_const, :RUBY_REVISION if defined?(RUBY_REVISION) - ua = Gem::Request.new(nil, nil, nil, nil).user_agent + ua = Gem::Request.new(@uri, nil, nil, nil).user_agent assert_match %r%\(#{Regexp.escape RUBY_RELEASE_DATE}\)%, ua ensure |