From c40b13d84f8a7a8ec15668f687826f40762bb1b2 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Sat, 5 Jul 2014 21:01:59 +1000 Subject: Search remote gem servers in reverse. This reverts to the documented behavior (http://bundler.io/v1.6/man/gemfile.5.html#SOURCE-PRIORITY) that regressed in v1.5.0. --- spec/install/gems/sources_spec.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 spec/install/gems/sources_spec.rb (limited to 'spec/install') diff --git a/spec/install/gems/sources_spec.rb b/spec/install/gems/sources_spec.rb new file mode 100644 index 0000000000..946eb9d296 --- /dev/null +++ b/spec/install/gems/sources_spec.rb @@ -0,0 +1,27 @@ +require "spec_helper" + +describe "bundle install with gems on multiple sources" do + # repo1 is built automatically before all of the specs run + # it contains rack-obama 1.0.0 and rack 0.9.1 & 1.0.0 amongst other gems + + it "searches gem sources from last to first" do + # Oh no! Someone evil is trying to hijack rack :( + # need this to be broken to check for correct source ordering + build_repo gem_repo3 do + build_gem "rack", "1.0.0" do |s| + s.write "lib/rack.rb", "RACK = 'FAIL'" + end + end + + gemfile <<-G + source "file://#{gem_repo3}" + source "file://#{gem_repo1}" + gem "rack-obama" + gem "rack" + G + + bundle :install + + should_be_installed("rack-obama 1.0.0", "rack 1.0.0") + end +end -- cgit v1.2.1 From ab78e7449ba1c1024de22ff798c6a32fb581abca Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Sun, 6 Jul 2014 18:35:31 +1000 Subject: Detect ambiguous gems. --- spec/install/gems/sources_spec.rb | 61 ++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 14 deletions(-) (limited to 'spec/install') diff --git a/spec/install/gems/sources_spec.rb b/spec/install/gems/sources_spec.rb index 946eb9d296..632a7ac3d7 100644 --- a/spec/install/gems/sources_spec.rb +++ b/spec/install/gems/sources_spec.rb @@ -4,24 +4,57 @@ describe "bundle install with gems on multiple sources" do # repo1 is built automatically before all of the specs run # it contains rack-obama 1.0.0 and rack 0.9.1 & 1.0.0 amongst other gems - it "searches gem sources from last to first" do - # Oh no! Someone evil is trying to hijack rack :( - # need this to be broken to check for correct source ordering - build_repo gem_repo3 do - build_gem "rack", "1.0.0" do |s| - s.write "lib/rack.rb", "RACK = 'FAIL'" + context "without source affinity" do + before do + # Oh no! Someone evil is trying to hijack rack :( + # need this to be broken to check for correct source ordering + build_repo gem_repo3 do + build_gem "rack", repo3_rack_version do |s| + s.write "lib/rack.rb", "RACK = 'FAIL'" + end end end - gemfile <<-G - source "file://#{gem_repo3}" - source "file://#{gem_repo1}" - gem "rack-obama" - gem "rack" - G + context "when the same version of the same gem is in multiple sources" do + let(:repo3_rack_version) { "1.0.0" } - bundle :install + before do + gemfile <<-G + source "file://#{gem_repo3}" + source "file://#{gem_repo1}" + gem "rack-obama" + gem "rack" + G + end + + it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first" do + bundle :install + + expect(out).to include("Warning: the gem 'rack' was found in multiple sources.") + expect(out).to include("Installed from: file:#{gem_repo1}") + should_be_installed("rack-obama 1.0.0", "rack 1.0.0") + end + end + + context "when different versions of the same gem are in multiple sources" do + let(:repo3_rack_version) { "1.2" } - should_be_installed("rack-obama 1.0.0", "rack 1.0.0") + before do + gemfile <<-G + source "file://#{gem_repo3}" + source "file://#{gem_repo1}" + gem "rack-obama" + gem "rack", "1.0.0" # force it to install the working version in repo1 + G + end + + it "warns about ambiguous gems, but installs anyway" do + bundle :install + + expect(out).to include("Warning: the gem 'rack' was found in multiple sources.") + expect(out).to include("Installed from: file:#{gem_repo1}") + should_be_installed("rack-obama 1.0.0", "rack 1.0.0") + end + end end end -- cgit v1.2.1 From 75c0bed53a9c90643a1139a7bb62890662840cb4 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Sun, 10 Feb 2013 14:53:47 -0800 Subject: allow rubygem sources via block or :source option --- spec/install/gems/sources_spec.rb | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'spec/install') diff --git a/spec/install/gems/sources_spec.rb b/spec/install/gems/sources_spec.rb index 632a7ac3d7..35d1278976 100644 --- a/spec/install/gems/sources_spec.rb +++ b/spec/install/gems/sources_spec.rb @@ -57,4 +57,56 @@ describe "bundle install with gems on multiple sources" do end end end + + context "with source affinity" do + context "with sources given by a block" do + before do + # Oh no! Someone evil is trying to hijack rack :( + # need this to be broken to check for correct source ordering + build_repo gem_repo3 do + build_gem "rack", "1.0.0" do |s| + s.write "lib/rack.rb", "RACK = 'FAIL'" + end + end + + gemfile <<-G + source "file://#{gem_repo3}" + source "file://#{gem_repo1}" do + gem "rack" + end + gem "rack-obama" # shoud come from repo3! + G + end + + it "installs the gems without any warning" do + bundle :install + expect(out).not_to include("Warning") + should_be_installed("rack-obama 1.0.0", "rack 1.0.0") + end + end + + context "with sources set by an option" do + before do + # Oh no! Someone evil is trying to hijack rack :( + # need this to be broken to check for correct source ordering + build_repo gem_repo3 do + build_gem "rack", "1.0.0" do |s| + s.write "lib/rack.rb", "RACK = 'FAIL'" + end + end + + gemfile <<-G + source "file://#{gem_repo3}" + gem "rack-obama" # should come from repo3! + gem "rack", :source => "file://#{gem_repo1}" + G + end + + it "installs the gems without any warning" do + bundle :install + expect(out).not_to include("Warning") + should_be_installed("rack-obama 1.0.0", "rack 1.0.0") + end + end + end end -- cgit v1.2.1 From c94b6fd6efcf71a8e147589f77963d0bce49c6cf Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Sun, 15 Jun 2014 19:18:31 +1000 Subject: Add tests for indirect dependencies. --- spec/install/gems/sources_spec.rb | 100 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) (limited to 'spec/install') diff --git a/spec/install/gems/sources_spec.rb b/spec/install/gems/sources_spec.rb index 35d1278976..20566f4cae 100644 --- a/spec/install/gems/sources_spec.rb +++ b/spec/install/gems/sources_spec.rb @@ -108,5 +108,105 @@ describe "bundle install with gems on multiple sources" do should_be_installed("rack-obama 1.0.0", "rack 1.0.0") end end + + context "with an indirect dependency" do + before do + build_repo gem_repo3 do + build_gem "depends_on_rack", "1.0.1" do |s| + s.add_dependency "rack" + end + end + end + + context "when the indirect dependency is in the pinned source" do + before do + # we need a working rack gem in repo3 + update_repo gem_repo3 do + build_gem "rack", "1.0.0" + end + + gemfile <<-G + source "file://#{gem_repo2}" + source "file://#{gem_repo3}" do + gem "depends_on_rack" + end + G + end + + context "and not in any other sources" do + before do + build_repo(gem_repo2) {} + end + + it "installs from the same source without any warning" do + bundle :install + expect(out).not_to include("Warning") + should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0") + end + end + + context "and in another source" do + before do + # need this to be broken to check for correct source ordering + build_repo gem_repo2 do + build_gem "rack", "1.0.0" do |s| + s.write "lib/rack.rb", "RACK = 'FAIL'" + end + end + end + + it "installs from the same source without any warning" do + bundle :install + expect(out).not_to include("Warning") + should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0") + end + end + end + + context "when the indirect dependency is in a different source" do + before do + # In these tests, we need a working rack gem in repo2 and not repo3 + build_repo gem_repo2 do + build_gem "rack", "1.0.0" + end + end + + context "and not in any other sources" do + before do + gemfile <<-G + source "file://#{gem_repo2}" + source "file://#{gem_repo3}" do + gem "depends_on_rack" + end + G + end + + it "installs from the other source without any warning" do + bundle :install + expect(out).not_to include("Warning") + should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0") + end + end + + context "and in yet another source" do + before do + gemfile <<-G + source "file://#{gem_repo1}" + source "file://#{gem_repo2}" + source "file://#{gem_repo3}" do + gem "depends_on_rack" + end + G + end + + it "installs from the other source and warns about ambiguous gems" do + bundle :install + expect(out).to include("Warning: the gem 'rack' was found in multiple sources.") + expect(out).to include("Installed from: file:#{gem_repo2}") + should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0") + end + end + end + end end end -- cgit v1.2.1 From e5bdbddb618394b4ae2b1b47ec6437ccd9aba264 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Thu, 17 Jul 2014 12:58:33 +1000 Subject: Don't warn on system gems. --- spec/install/gems/sources_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'spec/install') diff --git a/spec/install/gems/sources_spec.rb b/spec/install/gems/sources_spec.rb index 20566f4cae..cd4bcf1992 100644 --- a/spec/install/gems/sources_spec.rb +++ b/spec/install/gems/sources_spec.rb @@ -209,4 +209,21 @@ describe "bundle install with gems on multiple sources" do end end end + + context "when an older version of the same gem also ships with Ruby" do + before do + system_gems "rack-0.9.1" + + gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" # shoud come from repo1! + G + end + + it "installs the gems without any warning" do + bundle :install + expect(out).not_to include("Warning") + should_be_installed("rack 1.0.0") + end + end end -- cgit v1.2.1 From 65a647df088f2b59994eeabafbaf7ac425f82ea5 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Thu, 17 Jul 2014 14:34:03 +1000 Subject: Add a spec for gems not in the pinned source. --- spec/install/gems/sources_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'spec/install') diff --git a/spec/install/gems/sources_spec.rb b/spec/install/gems/sources_spec.rb index cd4bcf1992..d45e25c754 100644 --- a/spec/install/gems/sources_spec.rb +++ b/spec/install/gems/sources_spec.rb @@ -208,6 +208,24 @@ describe "bundle install with gems on multiple sources" do end end end + + context "with a gem that is only found in the wrong source" do + before do + build_repo gem_repo3 do + build_gem "not_in_repo1", "1.0.0" + end + + gemfile <<-G + source "file://#{gem_repo3}" + gem "not_in_repo1", :source => "file://#{gem_repo1}" + G + end + + it "does not install the gem" do + bundle :install + expect(out).to include("Could not find gem 'not_in_repo1 (>= 0) ruby'") + end + end end context "when an older version of the same gem also ships with Ruby" do -- cgit v1.2.1 From 3d7386d00bb0d8aecb7342dcb7e5b72a97518299 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Fri, 15 Aug 2014 08:14:14 +1000 Subject: Fix handling for sources with basic auth. Closes #3132. --- spec/install/deploy_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'spec/install') diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb index fdfe64bff0..c3ba3215b6 100644 --- a/spec/install/deploy_spec.rb +++ b/spec/install/deploy_spec.rb @@ -67,6 +67,18 @@ describe "install with --deployment or --frozen" do expect(exitstatus).to eq(0) end + it "works when there are credentials in the source URL" do + install_gemfile(<<-G, :artifice => "endpoint_strict_basic_authentication", :quiet => true) + source "http://user:pass@localgemserver.test/" + + gem "rack-obama", ">= 1.0" + G + + bundle "install --deployment", :exitstatus => true, :artifice => "endpoint_strict_basic_authentication" + + expect(exitstatus).to eq(0) + end + describe "with an existing lockfile" do before do bundle "install" -- cgit v1.2.1 From febd1b4f88d4280e159f00bb8f2623181121824a Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Tue, 19 Aug 2014 21:09:46 +1000 Subject: Update verification of dependency API fallback. --- spec/install/gems/dependency_api_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/install') diff --git a/spec/install/gems/dependency_api_spec.rb b/spec/install/gems/dependency_api_spec.rb index a01c89487e..b3e5edf468 100644 --- a/spec/install/gems/dependency_api_spec.rb +++ b/spec/install/gems/dependency_api_spec.rb @@ -157,8 +157,8 @@ describe "gemcutter's dependency API" do gem "rack" G - bundle :install, :artifice => "endpoint_marshal_fail" - expect(out).to include("Fetching source index from #{source_uri}") + bundle :install, :verbose => true, :artifice => "endpoint_marshal_fail" + expect(out).to include("could not fetch from the dependency API, trying the full index") should_be_installed "rack 1.0.0" end -- cgit v1.2.1