summaryrefslogtreecommitdiff
path: root/spec/install/gemfile
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-04-11 10:41:44 +0000
committerBundlerbot <bot@bundler.io>2019-04-11 10:41:44 +0000
commita6533c0fe6541cc929f895ee0b7a9b673d34cb4d (patch)
tree15201fd1b3c701b1be634c1f353f74b23c4f05aa /spec/install/gemfile
parent23772391d5f15835b1a540a4bd5ce16aac7ecc98 (diff)
parent59e989f3019c41daa807cc1e893263a873ebfb9b (diff)
downloadbundler-a6533c0fe6541cc929f895ee0b7a9b673d34cb4d.tar.gz
Merge #7057
7057: Review multiple sources deprecation r=indirect a=deivid-rodriguez ### What was the end-user problem that led to this PR? The problem was that I had not yet reviewed the deprecation about multiple global sources being present on a Gemfile, and thus the specs were skipped. ### What was your diagnosis of the problem? My diagnosis was that we need to delay the removal of multiple sources support to bundler 3, so that we can show the deprecations in the 2.x series. I also noticed that part of the deprecation message was inaccurate. In order to upgrade the warning to an error, you would also need to configure the `lockfile_uses_separate_rubygems_sources` setting. Otherwise you will get an error that these two settings depend on each other and can't be enabled separatedly. ### What is your fix for the problem, implemented in this PR? My fix is to delay these feature flags to bundler 3 so that the deprecation specs pass. Also, since before giving this advice I'd like to study why we have two different settings that can't be enabled separately, and why the can't be merged to a single one, I have removed that part of the message for now. ### Why did you choose this fix out of the possible options? I chose this fix because it keeps me moving with reviewing all the deprecations for bundler 3 breaking changes, and makes sure that the deprecations for this change of behavior are tested (and passing). Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
Diffstat (limited to 'spec/install/gemfile')
-rw-r--r--spec/install/gemfile/sources_spec.rb89
1 files changed, 60 insertions, 29 deletions
diff --git a/spec/install/gemfile/sources_spec.rb b/spec/install/gemfile/sources_spec.rb
index b0de8a1f20..8e1205dfa3 100644
--- a/spec/install/gemfile/sources_spec.rb
+++ b/spec/install/gemfile/sources_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
end
- context "with multiple toplevel sources", :bundler => "< 2" do
+ context "with multiple toplevel sources", :bundler => "< 3" do
let(:repo3_rack_version) { "1.0.0" }
before do
@@ -27,13 +27,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
G
end
- xit "shows a deprecation" do
- bundle :install
-
- expect(deprecations).to include("Your Gemfile contains multiple primary sources.")
- end
-
- it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first" do
+ it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first", :bundler => "2" do
bundle :install
expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
@@ -41,15 +35,14 @@ RSpec.describe "bundle install with gems on multiple sources" do
expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1")
end
- it "errors when disable_multisource is set" do
- bundle "config set disable_multisource true"
+ it "fails", :bundler => "3" do
bundle :install
expect(err).to include("Each source after the first must include a block")
expect(exitstatus).to eq(4) if exitstatus
end
end
- context "when different versions of the same gem are in multiple sources", :bundler => "< 2" do
+ context "when different versions of the same gem are in multiple sources", :bundler => "< 3" do
let(:repo3_rack_version) { "1.2" }
before do
@@ -63,15 +56,16 @@ RSpec.describe "bundle install with gems on multiple sources" do
bundle :install
end
- xit "shows a deprecation" do
- expect(deprecations).to include("Your Gemfile contains multiple primary sources.")
- end
-
- it "warns about ambiguous gems, but installs anyway" do
+ it "warns about ambiguous gems, but installs anyway", :bundler => "2" do
expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
expect(err).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo1}"))
expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1")
end
+
+ it "fails", :bundler => "3" do
+ expect(err).to include("Each source after the first must include a block")
+ expect(exitstatus).to eq(4) if exitstatus
+ end
end
end
@@ -193,9 +187,8 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
end
- context "when lockfile_uses_separate_rubygems_sources is set" do
+ context "when disable_multisource is set" do
before do
- bundle! "config set lockfile_uses_separate_rubygems_sources true"
bundle! "config set disable_multisource true"
end
@@ -243,7 +236,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
end
- context "and in yet another source", :bundler => "< 2" do
+ context "and in yet another source", :bundler => "< 3" do
before do
gemfile <<-G
source "file://localhost#{gem_repo1}"
@@ -256,18 +249,19 @@ RSpec.describe "bundle install with gems on multiple sources" do
bundle :install
end
- xit "shows a deprecation" do
- expect(deprecations).to include("Your Gemfile contains multiple primary sources.")
- end
-
- it "installs from the other source and warns about ambiguous gems" do
+ it "installs from the other source and warns about ambiguous gems", :bundler => "2" do
expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
expect(err).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo2}"))
expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
end
+
+ it "fails", :bundler => "3" do
+ expect(err).to include("Each source after the first must include a block")
+ expect(exitstatus).to eq(4) if exitstatus
+ end
end
- context "and only the dependency is pinned", :bundler => "< 2" do
+ context "and only the dependency is pinned", :bundler => "< 3" do
before do
# need this to be broken to check for correct source ordering
build_repo gem_repo2 do
@@ -285,7 +279,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
G
end
- it "installs the dependency from the pinned source without warning" do
+ it "installs the dependency from the pinned source without warning", :bundler => "2" do
bundle :install
expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.")
@@ -299,14 +293,19 @@ RSpec.describe "bundle install with gems on multiple sources" do
expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.")
expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
end
+
+ it "fails", :bundler => "3" do
+ bundle :install
+ expect(err).to include("Each source after the first must include a block")
+ expect(exitstatus).to eq(4) if exitstatus
+ end
end
end
end
context "when a top-level gem has an indirect dependency" do
- context "when lockfile_uses_separate_rubygems_sources is set" do
+ context "when disable_multisource is set" do
before do
- bundle! "config set lockfile_uses_separate_rubygems_sources true"
bundle! "config set disable_multisource true"
end
@@ -626,7 +625,39 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
end
- context "when a gem is available from multiple ambiguous sources", :bundler => "2" do
+ describe "source changed to one containing a higher version of a dependency" do
+ before do
+ install_gemfile! <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ G
+
+ build_repo2 do
+ build_gem "bar"
+ end
+
+ build_lib("gemspec_test", :path => tmp.join("gemspec_test")) do |s|
+ s.add_dependency "bar", "=1.0.0"
+ end
+
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "rack"
+ gemspec :path => "#{tmp.join("gemspec_test")}"
+ G
+ end
+
+ it "keeps the old version", :bundler => "2" do
+ expect(the_bundle).to include_gems("rack 1.0.0")
+ end
+
+ it "installs the higher version in the new repo", :bundler => "3" do
+ expect(the_bundle).to include_gems("rack 1.2")
+ end
+ end
+
+ context "when a gem is available from multiple ambiguous sources", :bundler => "3" do
it "raises, suggesting a source block" do
build_repo4 do
build_gem "depends_on_rack" do |s|