diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-11-11 10:40:30 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2021-11-22 10:51:35 +0900 |
commit | 31a71048521224774bdb8b5982ab73eb35dad66d (patch) | |
tree | 8174af2f04f4b31abf0f4ab08d779055f513cdaa /spec | |
parent | 6d540c1b9844a5832846618b53ce35d12d64deac (diff) |
Merge RubyGems 3.2.27 and Bundler 2.2.27
Diffstat (limited to 'spec')
-rw-r--r-- | spec/bundler/bundler/bundler_spec.rb | 6 | ||||
-rw-r--r-- | spec/bundler/bundler/env_spec.rb | 14 | ||||
-rw-r--r-- | spec/bundler/bundler/plugin_spec.rb | 7 | ||||
-rw-r--r-- | spec/bundler/commands/check_spec.rb | 52 | ||||
-rw-r--r-- | spec/bundler/commands/config_spec.rb | 8 | ||||
-rw-r--r-- | spec/bundler/plugins/command_spec.rb | 6 | ||||
-rw-r--r-- | spec/bundler/plugins/install_spec.rb | 21 |
7 files changed, 103 insertions, 11 deletions
diff --git a/spec/bundler/bundler/bundler_spec.rb b/spec/bundler/bundler/bundler_spec.rb index d164b5d3c6..b8191fe20f 100644 --- a/spec/bundler/bundler/bundler_spec.rb +++ b/spec/bundler/bundler/bundler_spec.rb @@ -176,11 +176,9 @@ RSpec.describe Bundler do describe "configuration" do context "disable_shared_gems" do it "should unset GEM_PATH with empty string" do - env = {} expect(Bundler).to receive(:use_system_gems?).and_return(false) - Bundler.send(:configure_gem_path, env) - expect(env.keys).to include("GEM_PATH") - expect(env["GEM_PATH"]).to eq "" + Bundler.send(:configure_gem_path) + expect(ENV["GEM_PATH"]).to eq "" end end end diff --git a/spec/bundler/bundler/env_spec.rb b/spec/bundler/bundler/env_spec.rb index 513c42ac09..8cd59311b2 100644 --- a/spec/bundler/bundler/env_spec.rb +++ b/spec/bundler/bundler/env_spec.rb @@ -126,6 +126,20 @@ RSpec.describe Bundler::Env do end end + context "when there's bundler config with OAuth token credentials" do + before do + bundle "config set https://localgemserver.test/ api_token:x-oauth-basic" + 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("[REDACTED]:x-oauth-basic") + expect(output).to_not include("api_token:x-oauth-basic") + 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/plugin_spec.rb b/spec/bundler/bundler/plugin_spec.rb index b75a9fa1b2..25cae014dd 100644 --- a/spec/bundler/bundler/plugin_spec.rb +++ b/spec/bundler/bundler/plugin_spec.rb @@ -67,6 +67,8 @@ RSpec.describe Bundler::Plugin do end it "passes the name and options to installer" do + allow(index).to receive(:installed?). + with("new-plugin") allow(installer).to receive(:install).with(["new-plugin"], opts) do { "new-plugin" => spec } end.once @@ -75,6 +77,8 @@ RSpec.describe Bundler::Plugin do end it "validates the installed plugin" do + allow(index).to receive(:installed?). + with("new-plugin") allow(subject). to receive(:validate_plugin!).with(lib_path("new-plugin")).once @@ -82,6 +86,8 @@ RSpec.describe Bundler::Plugin do end it "registers the plugin with index" do + allow(index).to receive(:installed?). + with("new-plugin") allow(index).to receive(:register_plugin). with("new-plugin", lib_path("new-plugin").to_s, [lib_path("new-plugin").join("lib").to_s], []).once subject.install ["new-plugin"], opts @@ -98,6 +104,7 @@ RSpec.describe Bundler::Plugin do end.once allow(subject).to receive(:validate_plugin!).twice + allow(index).to receive(:installed?).twice allow(index).to receive(:register_plugin).twice subject.install ["new-plugin", "another-plugin"], opts end diff --git a/spec/bundler/commands/check_spec.rb b/spec/bundler/commands/check_spec.rb index c48220f8df..419deae19b 100644 --- a/spec/bundler/commands/check_spec.rb +++ b/spec/bundler/commands/check_spec.rb @@ -137,6 +137,22 @@ RSpec.describe "bundle check" do expect(exitstatus).to eq(1) end + it "ensures that gems are actually installed and not just cached in applications' cache" do + gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + gem "rack" + G + + bundle "config set --local path vendor/bundle" + bundle :cache + + gem_command "uninstall rack", :env => { "GEM_HOME" => vendored_gems.to_s } + + bundle "check", :raise_on_error => false + expect(err).to include("* rack (1.0.0)") + expect(exitstatus).to eq(1) + end + it "ignores missing gems restricted to other platforms" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -316,6 +332,42 @@ RSpec.describe "bundle check" do end end + describe "when locked under multiple platforms" do + before :each do + build_repo4 do + build_gem "rack" + end + + gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "rack" + G + + lockfile <<-L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + rack (1.0) + + PLATFORMS + ruby + #{specific_local_platform} + + DEPENDENCIES + rack + + BUNDLED WITH + #{Bundler::VERSION} + L + end + + it "shows what is missing with the current Gemfile without duplications" do + bundle :check, :raise_on_error => false + expect(err).to match(/The following gems are missing/) + expect(err).to include("* rack (1.0").once + end + end + describe "when using only scoped rubygems sources" do before do gemfile <<~G diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb index 48f0ceab78..2d0a7dc989 100644 --- a/spec/bundler/commands/config_spec.rb +++ b/spec/bundler/commands/config_spec.rb @@ -440,6 +440,14 @@ E expect(out).to eq "gems.myserver.com=user:password\nspec_run=true" end + it "list with API token credentials" do + bundle "config list", :env => { "BUNDLE_GEMS__MYSERVER__COM" => "api_token:x-oauth-basic" } + 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: \"[REDACTED]:x-oauth-basic\"\n\nspec_run\nSet via BUNDLE_SPEC_RUN: \"true\"" + + bundle "config list", :parseable => true, :env => { "BUNDLE_GEMS__MYSERVER__COM" => "api_token:x-oauth-basic" } + expect(out).to eq "gems.myserver.com=api_token:x-oauth-basic\nspec_run=true" + end + it "get" do ENV["BUNDLE_BAR"] = "bar_val" diff --git a/spec/bundler/plugins/command_spec.rb b/spec/bundler/plugins/command_spec.rb index 4567a39081..3a7adf4b48 100644 --- a/spec/bundler/plugins/command_spec.rb +++ b/spec/bundler/plugins/command_spec.rb @@ -69,12 +69,10 @@ RSpec.describe "command plugins" do end end - bundle "plugin install copycat --source #{file_uri_for(gem_repo2)}" + bundle "plugin install copycat --source #{file_uri_for(gem_repo2)}", :raise_on_error => false expect(out).not_to include("Installed plugin copycat") - expect(err).to include("Failed to install the following plugins: `copycat`") - - expect(err).to include("Command(s) `mahcommand` declared by copycat are already registered.") + expect(err).to include("Failed to install plugin `copycat`, due to Bundler::Plugin::Index::CommandConflict (Command(s) `mahcommand` declared by copycat are already registered.)") end end diff --git a/spec/bundler/plugins/install_spec.rb b/spec/bundler/plugins/install_spec.rb index c719e8533e..009516260a 100644 --- a/spec/bundler/plugins/install_spec.rb +++ b/spec/bundler/plugins/install_spec.rb @@ -69,6 +69,21 @@ RSpec.describe "bundler plugin install" do plugin_should_be_installed("foo", "kung-foo") end + it "installs the latest version if not installed" do + update_repo2 do + build_plugin "foo", "1.1" + end + + bundle "plugin install foo --version 1.0 --source #{file_uri_for(gem_repo2)} --verbose" + expect(out).to include("Installing foo 1.0") + + bundle "plugin install foo --source #{file_uri_for(gem_repo2)} --verbose" + expect(out).to include("Installing foo 1.1") + + bundle "plugin install foo --source #{file_uri_for(gem_repo2)} --verbose" + expect(out).to include("Using foo 1.1") + end + it "works with different load paths" do build_repo2 do build_plugin "testing" do |s| @@ -109,9 +124,9 @@ RSpec.describe "bundler plugin install" do build_gem "charlie" end - bundle "plugin install charlie --source #{file_uri_for(gem_repo2)}" + bundle "plugin install charlie --source #{file_uri_for(gem_repo2)}", :raise_on_error => false - expect(err).to include("Failed to install the following plugins: `charlie`. The underlying error was: plugins.rb was not found") + expect(err).to include("Failed to install plugin `charlie`, due to Bundler::Plugin::MalformattedPlugin (plugins.rb was not found in the plugin.)") expect(global_plugin_gem("charlie-1.0")).not_to be_directory @@ -128,7 +143,7 @@ RSpec.describe "bundler plugin install" do end end - bundle "plugin install chaplin --source #{file_uri_for(gem_repo2)}" + bundle "plugin install chaplin --source #{file_uri_for(gem_repo2)}", :raise_on_error => false expect(global_plugin_gem("chaplin-1.0")).not_to be_directory |