summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2021-04-21 13:54:29 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-05-11 11:29:41 +0900
commit5b0abba9317f206913cf2e599d0dac7e9dbd0baa (patch)
tree81e092eaf8b048df4d64eebe8b1c51626f751e9b /spec
parent15160e9b4feba5d531601a4f626b3132d4749629 (diff)
Sync bundler & rubygems
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4367
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/bundler/compact_index_client/updater_spec.rb1
-rw-r--r--spec/bundler/bundler/env_spec.rb14
-rw-r--r--spec/bundler/bundler/fetcher/downloader_spec.rb5
-rw-r--r--spec/bundler/bundler/plugin/dsl_spec.rb2
-rw-r--r--spec/bundler/bundler/plugin/index_spec.rb2
-rw-r--r--spec/bundler/commands/cache_spec.rb25
-rw-r--r--spec/bundler/commands/clean_spec.rb2
-rw-r--r--spec/bundler/commands/config_spec.rb8
-rw-r--r--spec/bundler/commands/outdated_spec.rb353
-rw-r--r--spec/bundler/commands/pristine_spec.rb10
-rw-r--r--spec/bundler/commands/remove_spec.rb4
-rw-r--r--spec/bundler/commands/update_spec.rb295
-rw-r--r--spec/bundler/install/gemfile/gemspec_spec.rb53
-rw-r--r--spec/bundler/install/gemfile/sources_spec.rb11
-rw-r--r--spec/bundler/install/gems/compact_index_spec.rb33
-rw-r--r--spec/bundler/install/gems/dependency_api_spec.rb27
-rw-r--r--spec/bundler/install/gems/post_install_spec.rb2
-rw-r--r--spec/bundler/install/prereleases_spec.rb6
-rw-r--r--spec/bundler/quality_spec.rb10
-rw-r--r--spec/bundler/realworld/edgecases_spec.rb8
-rw-r--r--spec/bundler/runtime/inline_spec.rb2
-rw-r--r--spec/bundler/spec_helper.rb12
-rw-r--r--spec/bundler/support/artifice/compact_index.rb4
-rw-r--r--spec/bundler/support/artifice/compact_index_partial_update_no_etag_not_incremental.rb40
-rw-r--r--spec/bundler/support/artifice/endpoint.rb26
-rw-r--r--spec/bundler/support/artifice/windows.rb4
-rw-r--r--spec/bundler/support/builders.rb7
-rw-r--r--spec/bundler/support/helpers.rb4
-rw-r--r--spec/bundler/support/rubygems_ext.rb2
29 files changed, 823 insertions, 149 deletions
diff --git a/spec/bundler/bundler/compact_index_client/updater_spec.rb b/spec/bundler/bundler/compact_index_client/updater_spec.rb
index cecaddfba4..4acd7dbc63 100644
--- a/spec/bundler/bundler/compact_index_client/updater_spec.rb
+++ b/spec/bundler/bundler/compact_index_client/updater_spec.rb
@@ -38,7 +38,6 @@ RSpec.describe Bundler::CompactIndexClient::Updater do
context "when bundler doesn't have permissions on Dir.tmpdir" do
it "Errno::EACCES is raised" do
- local_path # create local path before stubbing mktmpdir
allow(Bundler::Dir).to receive(:mktmpdir) { raise Errno::EACCES }
expect do
diff --git a/spec/bundler/bundler/env_spec.rb b/spec/bundler/bundler/env_spec.rb
index 2cdead6eac..0dc19d1cf8 100644
--- a/spec/bundler/bundler/env_spec.rb
+++ b/spec/bundler/bundler/env_spec.rb
@@ -113,6 +113,20 @@ RSpec.describe Bundler::Env do
end
end
+ context "when there's bundler config with credentials" do
+ before do
+ bundle "config set https://localgemserver.test/ user:pass"
+ end
+
+ let(:output) { described_class.report(:print_gemfile => true) }
+
+ it "prints the config with redacted values" do
+ expect(output).to include("https://localgemserver.test")
+ expect(output).to include("user:[REDACTED]")
+ expect(output).to_not include("user:pass")
+ end
+ end
+
context "when Gemfile contains a gemspec and print_gemspecs is true" do
let(:gemspec) do
strip_whitespace(<<-GEMSPEC)
diff --git a/spec/bundler/bundler/fetcher/downloader_spec.rb b/spec/bundler/bundler/fetcher/downloader_spec.rb
index ba8451d9fa..667f484349 100644
--- a/spec/bundler/bundler/fetcher/downloader_spec.rb
+++ b/spec/bundler/bundler/fetcher/downloader_spec.rb
@@ -83,6 +83,11 @@ RSpec.describe Bundler::Fetcher::Downloader do
/Authentication is required for www.uri-to-fetch.com/)
end
+ it "should raise a Bundler::Fetcher::AuthenticationRequiredError with advices" do
+ expect { subject.fetch(uri, options, counter) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError,
+ /`bundle config set --global www\.uri-to-fetch\.com username:password`.*`BUNDLE_WWW__URI___TO___FETCH__COM`/m)
+ end
+
context "when the there are credentials provided in the request" do
let(:uri) { Bundler::URI("http://user:password@www.uri-to-fetch.com") }
diff --git a/spec/bundler/bundler/plugin/dsl_spec.rb b/spec/bundler/bundler/plugin/dsl_spec.rb
index be23db3bba..00e39dca69 100644
--- a/spec/bundler/bundler/plugin/dsl_spec.rb
+++ b/spec/bundler/bundler/plugin/dsl_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe Bundler::Plugin::DSL do
expect(dsl.inferred_plugins).to eq(["bundler-source-news"])
end
- it "registers a source type plugin only once for multiple declataions" do
+ it "registers a source type plugin only once for multiple declarations" do
expect(dsl).to receive(:plugin).with("bundler-source-news").and_call_original.once
dsl.source("some_random_url", :type => "news") {}
diff --git a/spec/bundler/bundler/plugin/index_spec.rb b/spec/bundler/bundler/plugin/index_spec.rb
index 925dc558ac..e7bde66879 100644
--- a/spec/bundler/bundler/plugin/index_spec.rb
+++ b/spec/bundler/bundler/plugin/index_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe Bundler::Plugin::Index do
expect(index.plugin_path(plugin_name)).to eq(lib_path(plugin_name))
end
- it "load_paths is available for retrival" do
+ it "load_paths is available for retrieval" do
expect(index.load_paths(plugin_name)).to eq([lib_path(plugin_name).join("lib").to_s])
end
diff --git a/spec/bundler/commands/cache_spec.rb b/spec/bundler/commands/cache_spec.rb
index 3b8bce4b01..df027a497a 100644
--- a/spec/bundler/commands/cache_spec.rb
+++ b/spec/bundler/commands/cache_spec.rb
@@ -211,14 +211,10 @@ RSpec.describe "bundle cache" do
end
context "with --all-platforms" do
- before do
- skip "doesn't put gems where it should" if Gem.win_platform?
- end
-
it "puts the gems in vendor/cache even for other rubies" do
gemfile <<-D
source "#{file_uri_for(gem_repo1)}"
- gem 'rack', :platforms => :ruby_19
+ gem 'rack', :platforms => [:ruby_20, :x64_mingw_20]
D
bundle "cache --all-platforms"
@@ -236,11 +232,11 @@ RSpec.describe "bundle cache" do
bundle "config set --local without wo"
install_gemfile <<-G
- source "file:#{gem_repo1}"
+ source "#{file_uri_for(gem_repo1)}"
gem "rack"
group :wo do
gem "weakling"
- gem "uninstallable", :source => "file:#{gem_repo4}"
+ gem "uninstallable", :source => "#{file_uri_for(gem_repo4)}"
end
G
@@ -255,6 +251,21 @@ RSpec.describe "bundle cache" do
expect(the_bundle).to include_gem "rack 1.0"
expect(the_bundle).not_to include_gems "weakling", "uninstallable"
end
+
+ it "does not fail to cache gems in excluded groups when there's a lockfile but gems not previously installed" do
+ bundle "config set --local without wo"
+ gemfile <<-G
+ source "https://my.gem.repo.1"
+ gem "rack"
+ group :wo do
+ gem "weakling"
+ end
+ G
+
+ bundle :lock, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo1.to_s }
+ bundle :cache, "all-platforms" => true, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo1.to_s }
+ expect(bundled_app("vendor/cache/weakling-0.0.3.gem")).to exist
+ end
end
context "with frozen configured" do
diff --git a/spec/bundler/commands/clean_spec.rb b/spec/bundler/commands/clean_spec.rb
index 7c43aaabc4..1889f6a197 100644
--- a/spec/bundler/commands/clean_spec.rb
+++ b/spec/bundler/commands/clean_spec.rb
@@ -199,7 +199,7 @@ RSpec.describe "bundle clean" do
revision = revision_for(git_path)
gemfile <<-G
- source "file://#{gem_repo1}"
+ source "#{file_uri_for(gem_repo1)}"
gem "rack", "1.0.0"
git "#{git_path}", :ref => "#{revision}" do
diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb
index a7c0813210..2f4488a552 100644
--- a/spec/bundler/commands/config_spec.rb
+++ b/spec/bundler/commands/config_spec.rb
@@ -408,6 +408,14 @@ E
expect(out).to eq "spec_run=true"
end
+ it "list with credentials" do
+ bundle "config list", :env => { "BUNDLE_GEMS__MYSERVER__COM" => "user:password" }
+ expect(out).to eq "Settings are listed in order of priority. The top value will be used.\ngems.myserver.com\nSet via BUNDLE_GEMS__MYSERVER__COM: \"user:[REDACTED]\"\n\nspec_run\nSet via BUNDLE_SPEC_RUN: \"true\""
+
+ bundle "config list", :parseable => true, :env => { "BUNDLE_GEMS__MYSERVER__COM" => "user:password" }
+ expect(out).to eq "gems.myserver.com=user:password\nspec_run=true"
+ end
+
it "get" do
ENV["BUNDLE_BAR"] = "bar_val"
diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb
index 7c4005824c..b0f0448655 100644
--- a/spec/bundler/commands/outdated_spec.rb
+++ b/spec/bundler/commands/outdated_spec.rb
@@ -1,24 +1,24 @@
# frozen_string_literal: true
RSpec.describe "bundle outdated" do
- before :each do
- build_repo2 do
- build_git "foo", :path => lib_path("foo")
- build_git "zebra", :path => lib_path("zebra")
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "zebra", :git => "#{lib_path("zebra")}"
- gem "foo", :git => "#{lib_path("foo")}"
- gem "activesupport", "2.3.5"
- gem "weakling", "~> 0.0.1"
- gem "duradura", '7.0'
- gem "terranova", '8'
- G
- end
-
describe "with no arguments" do
+ before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "zebra", :git => "#{lib_path("zebra")}"
+ gem "foo", :git => "#{lib_path("foo")}"
+ gem "activesupport", "2.3.5"
+ gem "weakling", "~> 0.0.1"
+ gem "duradura", '7.0'
+ gem "terranova", '8'
+ G
+ end
+
it "returns a sorted list of outdated gems" do
update_repo2 do
build_gem "activesupport", "3.0"
@@ -102,6 +102,23 @@ RSpec.describe "bundle outdated" do
end
describe "with --verbose option" do
+ before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "zebra", :git => "#{lib_path("zebra")}"
+ gem "foo", :git => "#{lib_path("foo")}"
+ gem "activesupport", "2.3.5"
+ gem "weakling", "~> 0.0.1"
+ gem "duradura", '7.0'
+ gem "terranova", '8'
+ G
+ end
+
it "shows the location of the latest version's gemspec if installed" do
bundle "config set clean false"
@@ -134,8 +151,79 @@ RSpec.describe "bundle outdated" do
end
end
+ describe "with multiple, duplicated sources, with lockfile in old format", :bundler => "< 3" do
+ before do
+ build_repo2 do
+ build_gem "dotenv", "2.7.6"
+
+ build_gem "oj", "3.11.3"
+ build_gem "oj", "3.11.5"
+
+ build_gem "vcr", "6.0.0"
+ end
+
+ build_repo gem_repo3 do
+ build_gem "pkg-gem-flowbyte-with-dep", "1.0.0" do |s|
+ s.add_dependency "oj"
+ end
+ end
+
+ gemfile <<~G
+ source "https://gem.repo2"
+
+ gem "dotenv"
+
+ source "https://gem.repo3" do
+ gem 'pkg-gem-flowbyte-with-dep'
+ end
+
+ gem "vcr",source: "https://gem.repo2"
+ G
+
+ lockfile <<~L
+ GEM
+ remote: https://gem.repo2/
+ remote: https://gem.repo3/
+ specs:
+ dotenv (2.7.6)
+ oj (3.11.3)
+ pkg-gem-flowbyte-with-dep (1.0.0)
+ oj
+ vcr (6.0.0)
+
+ PLATFORMS
+ #{specific_local_platform}
+
+ DEPENDENCIES
+ dotenv
+ pkg-gem-flowbyte-with-dep!
+ vcr!
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
+
+ it "works" do
+ bundle :install, :artifice => :compact_index
+ bundle :outdated, :artifice => :compact_index, :raise_on_error => false
+
+ expected_output = <<~TABLE
+ Gem Current Latest Requested Groups
+ oj 3.11.3 3.11.5
+ TABLE
+
+ expect(out).to include(expected_output.strip)
+ end
+ end
+
describe "with --group option" do
before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
@@ -201,7 +289,10 @@ RSpec.describe "bundle outdated" do
describe "with --groups option and outdated transitive dependencies" do
before do
- update_repo2 do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+
build_gem "bar", %w[2.0.0]
build_gem "bar_dependant", "7.0" do |s|
@@ -234,6 +325,11 @@ RSpec.describe "bundle outdated" do
describe "with --groups option" do
before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
@@ -272,6 +368,24 @@ RSpec.describe "bundle outdated" do
end
describe "with --local option" do
+ before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+
+ gem "weakling", "~> 0.0.1"
+ gem "terranova", '8'
+ group :development, :test do
+ gem 'activesupport', '2.3.5'
+ gem "duradura", '7.0'
+ end
+ G
+ end
+
it "uses local cache to return a list of outdated gems" do
update_repo2 do
build_gem "activesupport", "2.3.4"
@@ -305,10 +419,23 @@ RSpec.describe "bundle outdated" do
shared_examples_for "a minimal output is desired" do
context "and gems are outdated" do
before do
- update_repo2 do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+
build_gem "activesupport", "3.0"
build_gem "weakling", "0.2"
end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "zebra", :git => "#{lib_path("zebra")}"
+ gem "foo", :git => "#{lib_path("foo")}"
+ gem "activesupport", "2.3.5"
+ gem "weakling", "~> 0.0.1"
+ gem "duradura", '7.0'
+ gem "terranova", '8'
+ G
end
it "outputs a sorted list of outdated gems with a more minimal format" do
@@ -341,6 +468,21 @@ RSpec.describe "bundle outdated" do
describe "with specified gems" do
it "returns list of outdated gems" do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "zebra", :git => "#{lib_path("zebra")}"
+ gem "foo", :git => "#{lib_path("foo")}"
+ gem "activesupport", "2.3.5"
+ gem "weakling", "~> 0.0.1"
+ gem "duradura", '7.0'
+ gem "terranova", '8'
+ G
+
update_repo2 do
build_gem "activesupport", "3.0"
update_git "foo", :path => lib_path("foo")
@@ -358,6 +500,23 @@ RSpec.describe "bundle outdated" do
end
describe "pre-release gems" do
+ before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "zebra", :git => "#{lib_path("zebra")}"
+ gem "foo", :git => "#{lib_path("foo")}"
+ gem "activesupport", "2.3.5"
+ gem "weakling", "~> 0.0.1"
+ gem "duradura", '7.0'
+ gem "terranova", '8'
+ G
+ end
+
context "without the --pre option" do
it "ignores pre-release versions" do
update_repo2 do
@@ -413,6 +572,23 @@ RSpec.describe "bundle outdated" do
filter_strict_option = Bundler.feature_flag.bundler_2_mode? ? :"filter-strict" : :strict
describe "with --#{filter_strict_option} option" do
+ before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "zebra", :git => "#{lib_path("zebra")}"
+ gem "foo", :git => "#{lib_path("foo")}"
+ gem "activesupport", "2.3.5"
+ gem "weakling", "~> 0.0.1"
+ gem "duradura", '7.0'
+ gem "terranova", '8'
+ G
+ end
+
it "only reports gems that have a newer version that matches the specified dependency version requirements" do
update_repo2 do
build_gem "activesupport", "3.0"
@@ -521,6 +697,23 @@ RSpec.describe "bundle outdated" do
end
describe "with invalid gem name" do
+ before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "zebra", :git => "#{lib_path("zebra")}"
+ gem "foo", :git => "#{lib_path("foo")}"
+ gem "activesupport", "2.3.5"
+ gem "weakling", "~> 0.0.1"
+ gem "duradura", '7.0'
+ gem "terranova", '8'
+ G
+ end
+
it "returns could not find gem name" do
bundle "outdated invalid_gem_name", :raise_on_error => false
expect(err).to include("Could not find gem 'invalid_gem_name'.")
@@ -546,12 +739,16 @@ RSpec.describe "bundle outdated" do
context "after bundle install --deployment", :bundler => "< 3" do
before do
- install_gemfile <<-G, :deployment => true, :raise_on_error => false
+ build_repo2
+
+ gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "rack"
gem "foo"
G
+ bundle :lock
+ bundle :install, :deployment => true
end
it "outputs a helpful message about being in deployment mode" do
@@ -568,6 +765,11 @@ RSpec.describe "bundle outdated" do
context "after bundle config set --local deployment true" do
before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
@@ -591,6 +793,8 @@ RSpec.describe "bundle outdated" do
context "update available for a gem on a different platform" do
before do
+ build_repo2
+
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "laduradura", '= 5.15.2'
@@ -604,6 +808,10 @@ RSpec.describe "bundle outdated" do
end
context "update available for a gem on the same platform while multiple platforms used for gem" do
+ before do
+ build_repo2
+ end
+
it "reports that updates are available if the Ruby platform is used" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
@@ -643,6 +851,21 @@ RSpec.describe "bundle outdated" do
shared_examples_for "major version updates are detected" do
before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "zebra", :git => "#{lib_path("zebra")}"
+ gem "foo", :git => "#{lib_path("foo")}"
+ gem "activesupport", "2.3.5"
+ gem "weakling", "~> 0.0.1"
+ gem "duradura", '7.0'
+ gem "terranova", '8'
+ G
+
update_repo2 do
build_gem "activesupport", "3.3.5"
build_gem "weakling", "0.8.0"
@@ -654,6 +877,21 @@ RSpec.describe "bundle outdated" do
context "when on a new machine" do
before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "zebra", :git => "#{lib_path("zebra")}"
+ gem "foo", :git => "#{lib_path("foo")}"
+ gem "activesupport", "2.3.5"
+ gem "weakling", "~> 0.0.1"
+ gem "duradura", '7.0'
+ gem "terranova", '8'
+ G
+
simulate_new_machine
update_git "foo", :path => lib_path("foo")
@@ -669,6 +907,21 @@ RSpec.describe "bundle outdated" do
shared_examples_for "minor version updates are detected" do
before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "zebra", :git => "#{lib_path("zebra")}"
+ gem "foo", :git => "#{lib_path("foo")}"
+ gem "activesupport", "2.3.5"
+ gem "weakling", "~> 0.0.1"
+ gem "duradura", '7.0'
+ gem "terranova", '8'
+ G
+
update_repo2 do
build_gem "activesupport", "2.7.5"
build_gem "weakling", "2.0.1"
@@ -680,6 +933,21 @@ RSpec.describe "bundle outdated" do
shared_examples_for "patch version updates are detected" do
before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "zebra", :git => "#{lib_path("zebra")}"
+ gem "foo", :git => "#{lib_path("foo")}"
+ gem "activesupport", "2.3.5"
+ gem "weakling", "~> 0.0.1"
+ gem "duradura", '7.0'
+ gem "terranova", '8'
+ G
+
update_repo2 do
build_gem "activesupport", "2.3.7"
build_gem "weakling", "0.3.1"
@@ -698,6 +966,21 @@ RSpec.describe "bundle outdated" do
shared_examples_for "major version is ignored" do
before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "zebra", :git => "#{lib_path("zebra")}"
+ gem "foo", :git => "#{lib_path("foo")}"
+ gem "activesupport", "2.3.5"
+ gem "weakling", "~> 0.0.1"
+ gem "duradura", '7.0'
+ gem "terranova", '8'
+ G
+
update_repo2 do
build_gem "activesupport", "3.3.5"
build_gem "weakling", "1.0.1"
@@ -709,6 +992,21 @@ RSpec.describe "bundle outdated" do
shared_examples_for "minor version is ignored" do
before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "zebra", :git => "#{lib_path("zebra")}"
+ gem "foo", :git => "#{lib_path("foo")}"
+ gem "activesupport", "2.3.5"
+ gem "weakling", "~> 0.0.1"
+ gem "duradura", '7.0'
+ gem "terranova", '8'
+ G
+
update_repo2 do
build_gem "activesupport", "2.4.5"
build_gem "weakling", "0.3.1"
@@ -720,6 +1018,21 @@ RSpec.describe "bundle outdated" do
shared_examples_for "patch version is ignored" do
before do
+ build_repo2 do
+ build_git "foo", :path => lib_path("foo")
+ build_git "zebra", :path => lib_path("zebra")
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "zebra", :git => "#{lib_path("zebra")}"
+ gem "foo", :git => "#{lib_path("foo")}"
+ gem "activesupport", "2.3.5"
+ gem "weakling", "~> 0.0.1"
+ gem "duradura", '7.0'
+ gem "terranova", '8'
+ G
+
update_repo2 do
build_gem "activesupport", "2.3.6"
build_gem "weakling", "0.0.4"
diff --git a/spec/bundler/commands/pristine_spec.rb b/spec/bundler/commands/pristine_spec.rb
index 6978f302c1..2f730bd4e2 100644
--- a/spec/bundler/commands/pristine_spec.rb
+++ b/spec/bundler/commands/pristine_spec.rb
@@ -203,6 +203,16 @@ RSpec.describe "bundle pristine", :ruby_repo do
end
end
+ context "when BUNDLE_GEMFILE doesn't exist" do
+ before do
+ bundle "pristine", :env => { "BUNDLE_GEMFILE" => "does/not/exist" }, :raise_on_error => false
+ end
+
+ it "shows a meaningful error" do
+ expect(err).to eq("#{bundled_app("does/not/exist")} not found")
+ end
+ end
+
def find_spec(name)
without_env_side_effects do
Bundler.definition.specs[name].first
diff --git a/spec/bundler/commands/remove_spec.rb b/spec/bundler/commands/remove_spec.rb
index 46c42fea10..170545f80c 100644
--- a/spec/bundler/commands/remove_spec.rb
+++ b/spec/bundler/commands/remove_spec.rb
@@ -229,7 +229,7 @@ RSpec.describe "bundle remove" do
end
end
- context "when the gem is present in mutiple groups" do
+ context "when the gem is present in multiple groups" do
it "removes all empty blocks" do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@@ -333,7 +333,7 @@ RSpec.describe "bundle remove" do
end
describe "arbitrary gemfile" do
- context "when mutiple gems are present in same line" do
+ context "when multiple gems are present in same line" do
it "shows warning for gems not removed" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb
index 0f17d931a3..51a0b925a3 100644
--- a/spec/bundler/commands/update_spec.rb
+++ b/spec/bundler/commands/update_spec.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
RSpec.describe "bundle update" do
- before :each do
- build_repo2
+ describe "with no arguments" do
+ before do
+ build_repo2
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- gem "rack-obama"
- gem "platform_specific"
- G
- end
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "activesupport"
+ gem "rack-obama"
+ gem "platform_specific"
+ G
+ end
- describe "with no arguments", :bundler => "< 3" do
it "updates the entire bundle" do
update_repo2 do
build_gem "rack", "1.2" do |s|
@@ -39,7 +39,18 @@ RSpec.describe "bundle update" do
end
end
- describe "with --all", :bundler => "3" do
+ describe "with --all" do
+ before do
+ build_repo2
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "activesupport"
+ gem "rack-obama"
+ gem "platform_specific"
+ G
+ end
+
it "updates the entire bundle" do
update_repo2 do
build_gem "rack", "1.2" do |s|
@@ -55,6 +66,8 @@ RSpec.describe "bundle update" do
end
it "doesn't delete the Gemfile.lock file if something goes wrong" do
+ install_gemfile ""
+
gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
@@ -102,6 +115,17 @@ RSpec.describe "bundle update" do
end
describe "--quiet argument" do
+ before do
+ build_repo2
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "activesupport"
+ gem "rack-obama"
+ gem "platform_specific"
+ G
+ end
+
it "hides UI messages" do
bundle "update --quiet"
expect(out).not_to include("Bundle updated!")
@@ -109,6 +133,17 @@ RSpec.describe "bundle update" do
end
describe "with a top level dependency" do
+ before do
+ build_repo2
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "activesupport"
+ gem "rack-obama"
+ gem "platform_specific"
+ G
+ end
+
it "unlocks all child dependencies that are unrelated to other locked dependencies" do
update_repo2 do
build_gem "rack", "1.2" do |s|
@@ -124,6 +159,17 @@ RSpec.describe "bundle update" do
end
describe "with an unknown dependency" do
+ before do
+ build_repo2
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "activesupport"
+ gem "rack-obama"
+ gem "platform_specific"
+ G
+ end
+
it "should inform the user" do
bundle "update halting-problem-solver", :raise_on_error => false
expect(err).to include "Could not find gem 'halting-problem-solver'"
@@ -135,6 +181,17 @@ RSpec.describe "bundle update" do
end
describe "with a child dependency" do
+ before do
+ build_repo2
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "activesupport"
+ gem "rack-obama"
+ gem "platform_specific"
+ G
+ end
+
it "should update the child dependency" do
update_repo2 do
build_gem "rack", "1.2" do |s|
@@ -212,6 +269,17 @@ RSpec.describe "bundle update" do
end
describe "with --local option" do
+ before do
+ build_repo2
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "activesupport"
+ gem "rack-obama"
+ gem "platform_specific"
+ G
+ end
+
it "doesn't hit repo2" do
FileUtils.rm_rf(gem_repo2)
@@ -221,6 +289,10 @@ RSpec.describe "bundle update" do
end
describe "with --group option" do
+ before do
+ build_repo2
+ end
+
it "should update only specified group gems" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
@@ -257,7 +329,7 @@ RSpec.describe "bundle update" do
end
context "when there is a source with the same name as a gem in a group" do
- before :each do
+ before do
build_git "foo", :path => lib_path("activesupport")
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
@@ -299,6 +371,17 @@ RSpec.describe "bundle update" do
end
describe "in a frozen bundle" do
+ before do
+ build_repo2
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "activesupport"
+ gem "rack-obama"
+ gem "platform_specific"
+ G
+ end
+
it "should fail loudly", :bundler => "< 3" do
bundle "install --deployment"
bundle "update", :all => true, :raise_on_error => false
@@ -324,6 +407,10 @@ RSpec.describe "bundle update" do
end
describe "with --source option" do
+ before do
+ build_repo2
+ end
+
it "should not update gems not included in the source that happen to have the same name", :bundler => "< 3" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
@@ -449,10 +536,130 @@ RSpec.describe "bundle update" do
expect(the_bundle).to include_gems "harry 1.0", "fred 1.0", "george 1.0"
end
end
+
+ it "shows the previous version of the gem when updated from rubygems source", :bundler => "< 3" do
+ build_repo2
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "activesupport"
+ G
+
+ bundle "update", :all => true
+ expect(out).to include("Using activesupport 2.3.5")
+
+ update_repo2 do
+ build_gem "activesupport", "3.0"
+ end
+
+ bundle "update", :all => true
+ expect(out).to include("Installing activesupport 3.0 (was 2.3.5)")
+ end
+
+ context "with suppress_install_using_messages set" do
+ before { bundle "config set suppress_install_using_messages true" }
+
+ it "only prints `Using` for versions that have changed" do
+ build_repo4 do
+ build_gem "bar"
+ build_gem "foo"
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo4)}"
+ gem "bar"
+ gem "foo"
+ G
+
+ bundle "update", :all => true
+ expect(out).to match(/Resolving dependencies\.\.\.\.*\nBundle updated!/)
+
+ update_repo4 do
+ build_gem "foo", "2.0"
+ end
+
+ bundle "update", :all => true
+ out.sub!("Removing foo (1.0)\n", "")
+ expect(out).to match(/Resolving dependencies\.\.\.\.*\nFetching foo 2\.0 \(was 1\.0\)\nInstalling foo 2\.0 \(was 1\.0\)\nBundle updated/)
+ end
+ end
+
+ it "shows error message when Gemfile.lock is not preset and gem is specified" do
+ gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "activesupport"
+ G
+
+ bundle "update nonexisting", :raise_on_error => false
+ expect(err).to include("This Bundle hasn't been installed yet. Run `bundle install` to update and install the bundled gems.")
+ expect(exitstatus).to eq(22)
+ end
+
+ context "with multiple, duplicated sources, with lockfile in old format", :bundler => "< 3" do
+ before do
+ build_repo2 do
+ build_gem "dotenv", "2.7.6"
+
+ build_gem "oj", "3.11.3"
+ build_gem "oj", "3.11.5"
+
+ build_gem "vcr", "6.0.0"
+ end
+
+ build_repo gem_repo3 do
+ build_gem "pkg-gem-flowbyte-with-dep", "1.0.0" do |s|
+ s.add_dependency "oj"
+ end
+ end
+
+ gemfile <<~G
+ source "https://gem.repo2"
+
+ gem "dotenv"
+
+ source "https://gem.repo3" do
+ gem 'pkg-gem-flowbyte-with-dep'
+ end
+
+ gem "vcr",source: "https://gem.repo2"
+ G
+
+ lockfile <<~L
+ GEM
+ remote: https://gem.repo2/
+ remote: https://gem.repo3/
+ specs:
+ dotenv (2.7.6)
+ oj (3.11.3)
+ pkg-gem-flowbyte-with-dep (1.0.0)
+ oj
+ vcr (6.0.0)
+
+ PLATFORMS
+ #{specific_local_platform}
+
+ DEPENDENCIES
+ dotenv
+ pkg-gem-flowbyte-with-dep!
+ vcr!
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
+
+ it "works" do
+ bundle :install, :artifice => :compact_index
+ bundle "update oj", :artifice => :compact_index
+
+ expect(out).to include("Bundle updated!")
+ expect(the_bundle).to include_gems "oj 3.11.5"
+ end
+ end
end
RSpec.describe "bundle update in more complicated situations" do
- before :each do
+ before do
build_repo2
end
@@ -640,7 +847,7 @@ RSpec.describe "bundle update without a Gemfile.lock" do
end
RSpec.describe "bundle update when a gem depends on a newer version of bundler" do
- before(:each) do
+ before do
build_repo2 do
build_gem "rails", "3.0.1" do |s|
s.add_dependency "bundler", Bundler::VERSION.succ
@@ -663,66 +870,6 @@ RSpec.describe "bundle update when a gem depends on a newer version of bundler"
end
end
-RSpec.describe "bundle update" do
- it "shows the previous version of the gem when updated from rubygems source", :bundler => "< 3" do
- build_repo2
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- G
-
- bundle "update", :all => true
- expect(out).to include("Using activesupport 2.3.5")
-
- update_repo2 do
- build_gem "activesupport", "3.0"
- end
-
- bundle "update", :all => true
- expect(out).to include("Installing activesupport 3.0 (was 2.3.5)")
- end
-
- context "with suppress_install_using_messages set" do
- before { bundle "config set suppress_install_using_messages true" }
-
- it "only prints `Using` for versions that have changed" do
- build_repo4 do
- build_gem "bar"
- build_gem "foo"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "bar"
- gem "foo"
- G
-
- bundle "update", :all => true
- expect(out).to match(/Resolving dependencies\.\.\.\.*\nBundle updated!/)
-
- update_repo4 do
- build_gem "foo", "2.0"
- end
-
- bundle "update", :all => true
- out.sub!("Removing foo (1.0)\n", "")
- expect(out).to match(/Resolving dependencies\.\.\.\.*\nFetching foo 2\.0 \(was 1\.0\)\nInstalling foo 2\.0 \(was 1\.0\)\nBundle updated/)
- end
- end
-
- it "shows error message when Gemfile.lock is not preset and gem is specified" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- G
-
- bundle "update nonexisting", :raise_on_error => false
- expect(err).to include("This Bundle hasn't been installed yet. Run `bundle install` to update and install the bundled gems.")
- expect(exitstatus).to eq(22)
- end
-end
-
RSpec.describe "bundle update --ruby" do
before do
install_gemfile <<-G
diff --git a/spec/bundler/install/gemfile/gemspec_spec.rb b/spec/bundler/install/gemfile/gemspec_spec.rb
index ec6a1d4a4a..32dd7d24b8 100644
--- a/spec/bundler/install/gemfile/gemspec_spec.rb
+++ b/spec/bundler/install/gemfile/gemspec_spec.rb
@@ -567,4 +567,57 @@ RSpec.describe "bundle install from an existing gemspec" do
expect(the_bundle).not_to include_gem "rack"
end
end
+
+ context "with multiple platforms and resolving for more specific platforms" do
+ before do
+ build_lib("chef", :path => tmp.join("chef")) do |s|
+ s.version = "17.1.17"
+ s.write "chef-universal-mingw32.gemspec", build_spec("chef", "17.1.17", "universal-mingw32") {|sw| sw.runtime "win32-api", "~> 1.5.3" }.first.to_ruby
+ end
+ end
+
+ it "does not remove the platform specific specs from the lockfile when updating" do
+ build_repo4 do
+ build_gem "win32-api", "1.5.3" do |s|
+ s.platform = "universal-mingw32"
+ end
+ end
+
+ gemfile <<-G
+ source "#{file_uri_for(gem_repo4)}"
+ gemspec :path => "../chef"
+ G
+
+ initial_lockfile = <<~L
+ PATH
+ remote: ../chef
+ specs:
+ chef (17.1.17)
+ chef (17.1.17-universal-mingw32)
+ win32-api (~> 1.5.3)
+
+ GEM
+ remote: #{file_uri_for(gem_repo4)}/
+ specs:
+ win32-api (1.5.3-universal-mingw32)
+
+ PLATFORMS
+ ruby
+ x64-mingw32
+ x86-mingw32
+
+ DEPENDENCIES
+ chef!
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+
+ lockfile initial_lockfile
+
+ bundle "update"
+
+ expect(lockfile).to eq initial_lockfile
+ end
+ end
end
diff --git a/spec/bundler/install/gemfile/sources_spec.rb b/spec/bundler/install/gemfile/sources_spec.rb
index d86bc18311..4f931a493b 100644
--- a/spec/bundler/install/gemfile/sources_spec.rb
+++ b/spec/bundler/install/gemfile/sources_spec.rb
@@ -90,7 +90,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
gem "thin" # comes first to test name sorting
gem "rack"
end
- gem "rack-obama" # shoud come from repo3!
+ gem "rack-obama" # should come from repo3!
G
end
@@ -596,7 +596,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
L
end
- it "it keeps the currrent lockfile format and upgrades the requested gem when running bundle update with an argument, and warns", :bundler => "< 3" do
+ it "it keeps the current lockfile format and upgrades the requested gem when running bundle update with an argument, and warns", :bundler => "< 3" do
bundle "update concurrent-ruby"
expect(err).to include("Your lockfile contains a single rubygems source section with multiple remotes, which is insecure.")
@@ -921,7 +921,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
- gem "rack" # shoud come from repo1!
+ gem "rack" # should come from repo1!
G
end
@@ -974,7 +974,10 @@ RSpec.describe "bundle install with gems on multiple sources" do
context "re-resolving" do
context "when there is a mix of sources in the gemfile" do
before do
- build_repo3
+ build_repo gem_repo3 do
+ build_gem "rack"
+ end
+
build_lib "path1"
build_lib "path2"
build_git "git1"
diff --git a/spec/bundler/install/gems/compact_index_spec.rb b/spec/bundler/install/gems/compact_index_spec.rb
index 92cbd26b88..9454508e41 100644
--- a/spec/bundler/install/gems/compact_index_spec.rb
+++ b/spec/bundler/install/gems/compact_index_spec.rb
@@ -614,6 +614,17 @@ The checksum of /versions does not match the checksum provided by the server! So
expect(the_bundle).to include_gems "rack 1.0.0"
end
+ it "passes basic authentication details and strips out creds also in verbose mode" do
+ gemfile <<-G
+ source "#{basic_auth_source_uri}"
+ gem "rack"
+ G
+
+ bundle :install, :verbose => true, :artifice => "compact_index_basic_authentication"
+ expect(out).not_to include("#{user}:#{password}")
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
+
it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 3" do
gemfile <<-G
source "#{basic_auth_source_uri}"
@@ -815,6 +826,28 @@ The checksum of /versions does not match the checksum provided by the server! So
expect(the_bundle).to include_gems "rack 1.0.0"
end
+ it "performs full update if server endpoints serve partial content responses but don't have incremental content and provide no Etag" do
+ build_repo4 do
+ build_gem "rack", "0.9.1"
+ end
+
+ install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
+ source "#{source_uri}"
+ gem 'rack', '0.9.1'
+ G
+
+ update_repo4 do
+ build_gem "rack", "1.0.0"
+ end
+
+ install_gemfile <<-G, :artifice => "compact_index_partial_update_no_etag_not_incremental", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
+ source "#{source_uri}"
+ gem 'rack', '1.0.0'
+ G
+
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
+
it "performs full update of compact index info cache if range is not satisfiable" do
gemfile <<-G
source "#{source_uri}"
diff --git a/spec/bundler/install/gems/dependency_api_spec.rb b/spec/bundler/install/gems/dependency_api_spec.rb
index c23323682d..d8d2ac1668 100644
--- a/spec/bundler/install/gems/dependency_api_spec.rb
+++ b/spec/bundler/install/gems/dependency_api_spec.rb
@@ -586,6 +586,17 @@ RSpec.describe "gemcutter's dependency API" do
expect(the_bundle).to include_gems "rack 1.0.0"
end
+ it "passes basic authentication details and strips out creds also in verbose mode" do
+ gemfile <<-G
+ source "#{basic_auth_source_uri}"
+ gem "rack"
+ G
+
+ bundle :install, :verbose => true, :artifice => "endpoint_basic_authentication"
+ expect(out).not_to include("#{user}:#{password}")
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
+
it "strips http basic authentication creds for modern index" do
gemfile <<-G
source "#{basic_auth_source_uri}"
@@ -630,6 +641,22 @@ RSpec.describe "gemcutter's dependency API" do
expect(the_bundle).to include_gems "rack 1.0.0"
end
+ describe "with host including dashes" do
+ before do
+ gemfile <<-G
+ source "http://local-gemserver.test"
+ gem "rack"
+ G
+ end
+
+ it "reads authentication details from a valid ENV variable" do
+ bundle :install, :artifice => "endpoint_strict_basic_authentication", :env => { "BUNDLE_LOCAL___GEMSERVER__TEST" => "#{user}:#{password}" }
+
+ expect(out).to include("Fetching gem metadata from http://local-gemserver.test")
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
+ end
+
describe "with authentication details in bundle config" do
before do
gemfile <<-G
diff --git a/spec/bundler/install/gems/post_install_spec.rb b/spec/bundler/install/gems/post_install_spec.rb
index 3f6d7ce42c..7426f54877 100644
--- a/spec/bundler/install/gems/post_install_spec.rb
+++ b/spec/bundler/install/gems/post_install_spec.rb
@@ -33,7 +33,7 @@ RSpec.describe "bundle install" do
end
end
- context "when a dependecy includes a post install message" do
+ context "when a dependency includes a post install message" do
it "should display the post install message" do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
diff --git a/spec/bundler/install/prereleases_spec.rb b/spec/bundler/install/prereleases_spec.rb
index c3f968ad70..629eb89dac 100644
--- a/spec/bundler/install/prereleases_spec.rb
+++ b/spec/bundler/install/prereleases_spec.rb
@@ -38,7 +38,11 @@ RSpec.describe "bundle install" do
describe "when prerelease gems are not available" do
it "still works" do
- build_repo3
+ build_repo gem_repo3 do
+ build_gem "rack"
+ end
+ FileUtils.rm_rf Dir[gem_repo3("prerelease*")]
+
install_gemfile <<-G
source "#{file_uri_for(gem_repo3)}"
gem "rack"
diff --git a/spec/bundler/quality_spec.rb b/spec/bundler/quality_spec.rb
index dcdbf61f52..08ec8bed5c 100644
--- a/spec/bundler/quality_spec.rb
+++ b/spec/bundler/quality_spec.rb
@@ -170,9 +170,16 @@ RSpec.describe "The library itself" do
it "documents all used settings" do
exemptions = %w[
forget_cli_options
+ gem.changelog
+ gem.ci
gem.coc
+ gem.linter
gem.mit
+ gem.rubocop
+ gem.test
+ git.allow_insecure
inline
+ trust-policy
use_gem_version_promoter_for_major_updates
]
@@ -182,6 +189,7 @@ RSpec.describe "The library itself" do
Bundler::Settings::BOOL_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::BOOL_KEYS" }
Bundler::Settings::NUMBER_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::NUMBER_KEYS" }
Bundler::Settings::ARRAY_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::ARRAY_KEYS" }
+ Bundler::Settings::STRING_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::STRING_KEYS" }
key_pattern = /([a-z\._-]+)/i
lib_tracked_files.each do |filename|
@@ -215,7 +223,7 @@ RSpec.describe "The library itself" do
end
it "ships the correct set of files" do
- git_list = git_ls_files(ruby_core? ? "lib/bundler lib/bundler.rb man/bundle* man/gemfile* libexec/bundle*" : "lib man exe CHANGELOG.md LICENSE.md README.md bundler.gemspec")
+ git_list = git_ls_files(ruby_core? ? "lib/bundler lib/bundler.rb libexec/bundle*" : "lib exe CHANGELOG.md LICENSE.md README.md bundler.gemspec")
gem_list = loaded_gemspec.files
diff --git a/spec/bundler/realworld/edgecases_spec.rb b/spec/bundler/realworld/edgecases_spec.rb
index 1925f76c06..9f6ae399af 100644
--- a/spec/bundler/realworld/edgecases_spec.rb
+++ b/spec/bundler/realworld/edgecases_spec.rb
@@ -349,14 +349,14 @@ RSpec.describe "real world edgecases", :realworld => true do
end
it "doesn't hang on big gemfile" do
- skip "Only for ruby 2.7.2" if RUBY_VERSION != "2.7.2"
+ skip "Only for ruby 2.7.3" if RUBY_VERSION != "2.7.3"
gemfile <<~G
# frozen_string_literal: true
source "https://rubygems.org"
- ruby "2.7.2"
+ ruby "2.7.3"
gem "rails"
gem "pg", ">= 0.18", "< 2.0"
@@ -461,7 +461,7 @@ RSpec.describe "real world edgecases", :realworld => true do
end
it "doesn't hang on tricky gemfile" do
- skip "Only for ruby 2.7.2" if RUBY_VERSION != "2.7.2"
+ skip "Only for ruby 2.7.3" if RUBY_VERSION != "2.7.3"
gemfile <<~G
source 'https://rubygems.org'
@@ -487,7 +487,7 @@ RSpec.describe "real world edgecases", :realworld => true do
end
it "doesn't hang on nix gemfile" do
- skip "Only for ruby 3.0.0" if RUBY_VERSION != "3.0.0"
+ skip "Only for ruby 3.0.1" if RUBY_VERSION != "3.0.1"
gemfile <<~G
source "https://rubygems.org" do
diff --git a/spec/bundler/runtime/inline_spec.rb b/spec/bundler/runtime/inline_spec.rb
index bad1df93a9..57b7392608 100644
--- a/spec/bundler/runtime/inline_spec.rb
+++ b/spec/bundler/runtime/inline_spec.rb
@@ -293,7 +293,7 @@ RSpec.describe "bundler/inline#gemfile" do
it "installs inline gems to the system path regardless" do
script <<-RUBY, :env => { "BUNDLE_PATH" => "./vendor/inline" }
gemfile(true) do
- source "file://#{gem_repo1}"
+ source "#{file_uri_for(gem_repo1)}"
gem "rack"
end
RUBY
diff --git a/spec/bundler/spec_helper.rb b/spec/bundler/spec_helper.rb
index 99be2f4df8..dc4121cb70 100644
--- a/spec/bundler/spec_helper.rb
+++ b/spec/bundler/spec_helper.rb
@@ -4,7 +4,6 @@ require "bundler/psyched_yaml"
require "bundler/vendored_fileutils"
require "bundler/vendored_uri"
require "digest"
-require "tmpdir"
if File.expand_path(__FILE__) =~ %r{([^\w/\.:\-])}
abort "The bundler specs cannot be run from a path that contains special characters (particularly #{$1.inspect})"
@@ -74,6 +73,7 @@ RSpec.configure do |config|
Spec::Rubygems.test_setup
ENV["BUNDLE_SPEC_RUN"] = "true"
ENV["BUNDLE_USER_CONFIG"] = ENV["BUNDLE_USER_CACHE"] = ENV["BUNDLE_USER_PLUGIN"] = nil
+ ENV["XDG_CONFIG_HOME"] = nil
ENV["GEMRC"] = nil
# Don't wrap output in tests
@@ -111,16 +111,6 @@ RSpec.configure do |config|
end
end
- config.around :each do |example|
- Dir.mktmpdir("bundler_commands_console") do |dir|
- xdg_config_home_backup = ENV.delete("XDG_CONFIG_HOME")
- ENV["XDG_CONFIG_HOME"] = dir
- example.run
- ensure
- ENV["XDG_CONFIG_HOME"] = xdg_config_home_backup
- end
- end
-
config.after :suite do
FileUtils.rm_r Spec::Path.pristine_system_gem_path
end
diff --git a/spec/bundler/support/artifice/compact_index.rb b/spec/bundler/support/artifice/compact_index.rb
index 5cf3a79f29..1b314e89ef 100644
--- a/spec/bundler/support/artifice/compact_index.rb
+++ b/spec/bundler/support/artifice/compact_index.rb
@@ -62,7 +62,7 @@ class CompactIndexAPI < Endpoint
body.byteslice(range)
end
- def gems(gem_repo = GEM_REPO)
+ def gems(gem_repo = default_gem_repo)
@gems ||= {}
@gems[gem_repo] ||= begin
specs = Bundler::Deprecate.skip_during do
@@ -80,7 +80,7 @@ class CompactIndexAPI < Endpoint
CompactIndex::Dependency.new(d.name, reqs)
end
checksum = begin
- Digest(:SHA256).file("#{GEM_REPO}/gems/#{spec.original_name}.gem").base64digest
+ Digest(:SHA256).file("#{gem_repo}/gems/#{spec.original_name}.gem").base64digest
rescue StandardError
nil
end
diff --git a/spec/bundler/support/artifice/compact_index_partial_update_no_etag_not_incremental.rb b/spec/bundler/support/artifice/compact_index_partial_update_no_etag_not_incremental.rb
new file mode 100644
index 0000000000..acf76dfbf0
--- /dev/null
+++ b/spec/bundler/support/artifice/compact_index_partial_update_no_etag_not_incremental.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+require_relative "compact_index"
+
+Artifice.deactivate
+
+class CompactIndexPartialUpdateNoEtagNotIncremental < CompactIndexAPI
+ def partial_update_no_etag
+ response_body = yield
+ headers "Surrogate-Control" => "max-age=2592000, stale-while-revalidate=60"
+ content_type "text/plain"
+ requested_range_for(response_body)
+ end
+
+ get "/versions" do
+ partial_update_no_etag do
+ file = tmp("versions.list")
+ FileUtils.rm_f(file)
+ file = CompactIndex::VersionsFile.new(file.to_s)
+ file.create(gems)
+ lines = file.contents([], :calculate_info_checksums => true).split("\n")
+ name, versions, checksum = lines.last.split(" ")
+
+ # shuffle versions so new versions are not appended to the end
+ [*lines[0..-2], [name, versions.split(",").reverse.join(","), checksum].join(" ")].join("\n")
+ end
+ end
+
+ get "/info/:name" do
+ partial_update_no_etag do
+ gem = gems.find {|g| g.name == params[:name] }
+ lines = CompactIndex.info(gem ? gem.versions : []).split("\n")
+
+ # shuffle versions so new versions are not appended to the end
+ [lines.first, lines.last, *lines[1..-2]].join("\n")
+ end
+ end
+end
+
+Artifice.activate_with(CompactIndexPartialUpdateNoEtagNotIncremental)
diff --git a/spec/bundler/support/artifice/endpoint.rb b/spec/bundler/support/artifice/endpoint.rb
index 1dc7101389..e0650fa7d5 100644
--- a/spec/bundler/support/artifice/endpoint.rb
+++ b/spec/bundler/support/artifice/endpoint.rb
@@ -26,7 +26,6 @@ class Endpoint < Sinatra::Base
@all_requests ||= []
end
- GEM_REPO = Pathname.new(ENV["BUNDLER_SPEC_GEM_REPO"] || Spec::Path.gem_repo1)
set :raise_errors, true
set :show_exceptions, false
@@ -41,7 +40,22 @@ class Endpoint < Sinatra::Base
helpers do
include Spec::Path
- def dependencies_for(gem_names, gem_repo = GEM_REPO)
+ def default_gem_repo
+ if ENV["BUNDLER_SPEC_GEM_REPO"]
+ Pathname.new(ENV["BUNDLER_SPEC_GEM_REPO"])
+ else
+ case request.host
+ when "gem.repo2"
+ Spec::Path.gem_repo2
+ when "gem.repo3"
+ Spec::Path.gem_repo3
+ else
+ Spec::Path.gem_repo1
+ end
+ end
+ end
+
+ def dependencies_for(gem_names, gem_repo = default_gem_repo)
return [] if gem_names.nil? || gem_names.empty?
all_specs = %w[specs.4.8 prerelease_specs.4.8].map do |filename|
@@ -74,11 +88,11 @@ class Endpoint < Sinatra::Base
end
get "/fetch/actual/gem/:id" do
- File.binread("#{GEM_REPO}/quick/Marshal.4.8/#{params[:id]}")
+ File.binread("#{default_gem_repo}/quick/Marshal.4.8/#{params[:id]}")
end
get "/gems/:id" do
- File.binread("#{GEM_REPO}/gems/#{params[:id]}")
+ File.binread("#{default_gem_repo}/gems/#{params[:id]}")
end
get "/api/v1/dependencies" do
@@ -86,11 +100,11 @@ class Endpoint < Sinatra::Base
end
get "/specs.4.8.gz" do
- File.binread("#{GEM_REPO}/specs.4.8.gz")
+ File.binread("#{default_gem_repo}/specs.4.8.gz")
end
get "/prerelease_specs.4.8.gz" do
- File.binread("#{GEM_REPO}/prerelease_specs.4.8.gz")
+ File.binread("#{default_gem_repo}/prerelease_specs.4.8.gz")
end
end
diff --git a/spec/bundler/support/artifice/windows.rb b/spec/bundler/support/artifice/windows.rb
index f5b4baae30..ddbbd62b96 100644
--- a/spec/bundler/support/artifice/windows.rb
+++ b/spec/bundler/support/artifice/windows.rb
@@ -14,7 +14,7 @@ class Windows < Sinatra::Base
set :show_exceptions, false
helpers do
- def gem_repo
+ def default_gem_repo
Pathname.new(ENV["BUNDLER_SPEC_GEM_REPO"] || Spec::Path.gem_repo1)
end
end
@@ -26,7 +26,7 @@ class Windows < Sinatra::Base
files.each do |file|
get "/#{file}" do
- File.binread gem_repo.join(file)
+ File.binread default_gem_repo.join(file)
end
end
diff --git a/spec/bundler/support/builders.rb b/spec/bundler/support/builders.rb
index d593ced27e..25377d2ac2 100644
--- a/spec/bundler/support/builders.rb
+++ b/spec/bundler/support/builders.rb
@@ -192,13 +192,6 @@ module Spec
update_repo2(&blk) if block_given?
end
- def build_repo3
- build_repo gem_repo3 do
- build_gem "rack"
- end
- FileUtils.rm_rf Dir[gem_repo3("prerelease*")]
- end
-
# A repo that has no pre-installed gems included. (The caller completely
# determines the contents with the block.)
def build_repo4(&blk)
diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb
index d896b5276e..6fb0c6cb1c 100644
--- a/spec/bundler/support/helpers.rb
+++ b/spec/bundler/support/helpers.rb
@@ -87,9 +87,11 @@ module Spec
env = options.delete(:env) || {}
requires = options.delete(:requires) || []
+ realworld = RSpec.current_example.metadata[:realworld]
+ options[:verbose] = true if options[:verbose].nil? && realworld
artifice = options.delete(:artifice) do
- if RSpec.current_example.metadata[:realworld]
+ if realworld
"vcr"
else
"fail"
diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb
index ea774429c9..9389543a0f 100644
--- a/spec/bundler/support/rubygems_ext.rb
+++ b/spec/bundler/support/rubygems_ext.rb
@@ -98,7 +98,7 @@ module Spec
gem_activate(gem_name)
load Gem.bin_path(gem_name, bin_container)
rescue Gem::LoadError => e
- abort "We couln't activate #{gem_name} (#{e.requirement}). Run `gem install #{gem_name}:'#{e.requirement}'`"
+ abort "We couldn't activate #{gem_name} (#{e.requirement}). Run `gem install #{gem_name}:'#{e.requirement}'`"
end
def gem_activate(gem_name)