summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-04-05 12:24:11 +0200
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-04-08 13:45:37 +0200
commit59e989f3019c41daa807cc1e893263a873ebfb9b (patch)
tree55ea27d69c2c3d0ec5867cca6ee3b9c8c0a9764a
parent7cf4ac2e6b5bbec487ab9a44b898733ae4b4208e (diff)
downloadbundler-59e989f3019c41daa807cc1e893263a873ebfb9b.tar.gz
Refactor list specs to not change gemfile sourcesmultiple_sources_deprecation
Previously, all specs would bundle a Gemfile from the "repo1" source by default. Then, some list specs would end up using a "repo2" source. The behavior when changing repo sources is changing with the `disable_multisource` setting, but it is unrelated to the list command. So, I refactored the list command specs to not change sources, and extracted the behavior change about changing sources to a separate spec.
-rw-r--r--spec/commands/list_spec.rb70
-rw-r--r--spec/install/gemfile/sources_spec.rb32
2 files changed, 87 insertions, 15 deletions
diff --git a/spec/commands/list_spec.rb b/spec/commands/list_spec.rb
index d87b7c27da..e88d7bfb04 100644
--- a/spec/commands/list_spec.rb
+++ b/spec/commands/list_spec.rb
@@ -1,15 +1,6 @@
# frozen_string_literal: true
RSpec.describe "bundle list", :bundler => ">= 2" do
- before do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
-
- gem "rack"
- gem "rspec", :group => [:test]
- G
- end
-
context "with name-only and paths option" do
it "raises an error" do
bundle "list --name-only --paths"
@@ -27,6 +18,15 @@ RSpec.describe "bundle list", :bundler => ">= 2" do
end
describe "with without-group option" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ gem "rspec", :group => [:test]
+ G
+ end
+
context "when group is present" do
it "prints the gems not in the specified group" do
bundle! "list --without-group test"
@@ -46,6 +46,15 @@ RSpec.describe "bundle list", :bundler => ">= 2" do
end
describe "with only-group option" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ gem "rspec", :group => [:test]
+ G
+ end
+
context "when group is present" do
it "prints the gems in the specified group" do
bundle! "list --only-group default"
@@ -65,6 +74,15 @@ RSpec.describe "bundle list", :bundler => ">= 2" do
end
context "with name-only option" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ gem "rspec", :group => [:test]
+ G
+ end
+
it "prints only the name of the gems in the bundle" do
bundle "list --name-only"
@@ -116,13 +134,35 @@ RSpec.describe "bundle list", :bundler => ">= 2" do
end
end
- it "lists gems installed in the bundle" do
- bundle "list"
- expect(out).to include(" * rack (1.0.0)")
+ context "without options" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ gem "rspec", :group => [:test]
+ G
+ end
+
+ it "lists gems installed in the bundle" do
+ bundle "list"
+ expect(out).to include(" * rack (1.0.0)")
+ end
end
- it "aliases the ls command to list" do
- bundle "ls"
- expect(out).to include("Gems included by the bundle")
+ context "when using the ls alias" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ gem "rspec", :group => [:test]
+ G
+ end
+
+ it "runs the list command" do
+ bundle "ls"
+ expect(out).to include("Gems included by the bundle")
+ end
end
end
diff --git a/spec/install/gemfile/sources_spec.rb b/spec/install/gemfile/sources_spec.rb
index 28494102fb..8e1205dfa3 100644
--- a/spec/install/gemfile/sources_spec.rb
+++ b/spec/install/gemfile/sources_spec.rb
@@ -625,6 +625,38 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
end
+ 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