summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadayuki Furuhashi <frsyuki@gmail.com>2015-07-30 15:06:36 -0700
committerSadayuki Furuhashi <frsyuki@gmail.com>2015-07-30 15:06:36 -0700
commit832dedd72b9cd90aa2b909ce81c066398cc94974 (patch)
tree31e3e32c9359e3bc0eb1998df7eb49782221fbbe
parent2be8d87976c01221a92ac96e852b11b9518f6c01 (diff)
downloadbundler-832dedd72b9cd90aa2b909ce81c066398cc94974.tar.gz
Added unit tests for GitProxy#configured_uri_for
-rw-r--r--spec/bundler/source/git/git_proxy_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/bundler/source/git/git_proxy_spec.rb b/spec/bundler/source/git/git_proxy_spec.rb
new file mode 100644
index 0000000000..7e2083d595
--- /dev/null
+++ b/spec/bundler/source/git/git_proxy_spec.rb
@@ -0,0 +1,34 @@
+require "spec_helper"
+
+describe Bundler::Source::Git::GitProxy do
+ let(:uri) { "https://github.com/bundler/bundler.git" }
+ subject { described_class.new(Pathname("path"), uri, "HEAD") }
+
+ context "with configured credentials" do
+ it "adds username and password to URI" do
+ Bundler.settings[uri] = "u:p"
+ expect(subject).to receive(:git_retry).with(match("https://u:p@github.com/bundler/bundler.git"))
+ subject.checkout
+ end
+
+ it "adds username and password to URI for host" do
+ Bundler.settings["github.com"] = "u:p"
+ expect(subject).to receive(:git_retry).with(match("https://u:p@github.com/bundler/bundler.git"))
+ subject.checkout
+ end
+
+ it "does not add username and password to mismatched URI" do
+ Bundler.settings["https://u:p@github.com/bundler/bundler-mismatch.git"] = "u:p"
+ expect(subject).to receive(:git_retry).with(match(uri))
+ subject.checkout
+ end
+
+ it "keeps original userinfo" do
+ Bundler.settings["github.com"] = "u:p"
+ original = "https://orig:info@github.com/bundler/bundler.git"
+ subject = described_class.new(Pathname("path"), original, "HEAD")
+ expect(subject).to receive(:git_retry).with(match(original))
+ subject.checkout
+ end
+ end
+end