summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHirotaka Azuma <azuma@scaleout.jp>2015-07-17 05:28:24 +0000
committerAndre Arko <andre@arko.net>2015-08-14 19:58:17 -0700
commit761207ede1d11261c3f7ae0355005472d6816ae4 (patch)
treee2186966ee9f1f931de9223dadd4a3eb12397e63
parentd5ce178ebba5fff5773f2d87de482ddb16fc4ab2 (diff)
downloadbundler-761207ede1d11261c3f7ae0355005472d6816ae4.tar.gz
Append specs.
-rw-r--r--lib/bundler/fetcher.rb8
-rw-r--r--spec/bundler/fetcher_spec.rb26
2 files changed, 34 insertions, 0 deletions
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb
index e978cadfa2..15e568cb9e 100644
--- a/lib/bundler/fetcher.rb
+++ b/lib/bundler/fetcher.rb
@@ -172,6 +172,14 @@ module Bundler
@fetchers ||= FETCHERS.map {|f| f.new(downloader, remote_uri, fetch_uri, uri) }
end
+ def http_proxy
+ if uri = connection.proxy_uri
+ uri.to_s
+ else
+ nil
+ end
+ end
+
def inspect
"#<#{self.class}:0x#{object_id} uri=#{uri}>"
end
diff --git a/spec/bundler/fetcher_spec.rb b/spec/bundler/fetcher_spec.rb
index 622c25d287..d99371f3b1 100644
--- a/spec/bundler/fetcher_spec.rb
+++ b/spec/bundler/fetcher_spec.rb
@@ -8,6 +8,32 @@ describe Bundler::Fetcher do
allow(Bundler).to receive(:root) { Pathname.new("root") }
end
+ describe "#connection" do
+ context "when Gem.configuration doesn't specify http_proxy" do
+ it "specify no http_proxy" do
+ expect(fetcher.http_proxy).to be_nil
+ end
+ it "consider environment vars when determine proxy" do
+ with_env_vars({"HTTP_PROXY" => "http://proxy-example.com"}) do
+ expect(fetcher.http_proxy).to match("http://proxy-example.com")
+ end
+ end
+ end
+ context "when Gem.configuration specifies http_proxy " do
+ before do
+ allow(Bundler.rubygems.configuration).to receive(:[]).and_return("http://proxy-example2.com")
+ end
+ it "consider Gem.configuration when determine proxy" do
+ expect(fetcher.http_proxy).to match("http://proxy-example2.com")
+ end
+ it "consider Gem.configuration when determine proxy" do
+ with_env_vars({"HTTP_PROXY" => "http://proxy-example.com"}) do
+ expect(fetcher.http_proxy).to match("http://proxy-example2.com")
+ end
+ end
+ end
+ end
+
describe "#user_agent" do
it "builds user_agent with current ruby version and Bundler settings" do
allow(Bundler.settings).to receive(:all).and_return(%w[foo bar])