diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-14 06:01:35 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-14 06:01:35 +0000 |
commit | 68ddd4d300e9a88737c4f37af74e1a0312949b2f (patch) | |
tree | 787e1e83d76934ce039eb336995a8d5bb53a89e6 /spec/bundler/other | |
parent | d636809c057432e8d42abe30c6c6785eb0721d77 (diff) | |
download | ruby-68ddd4d300e9a88737c4f37af74e1a0312949b2f.tar.gz |
Merge Bundler 2.1.0.pre.1 as developed version from upstream.
https://github.com/bundler/bundler/commit/a53709556b95a914e874b22ed2116a46b0528852
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/bundler/other')
-rw-r--r-- | spec/bundler/other/bundle_ruby_spec.rb | 155 | ||||
-rw-r--r-- | spec/bundler/other/cli_dispatch_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/other/compatibility_guard_spec.rb | 9 | ||||
-rw-r--r-- | spec/bundler/other/ext_spec.rb | 7 | ||||
-rw-r--r-- | spec/bundler/other/major_deprecation_spec.rb | 473 | ||||
-rw-r--r-- | spec/bundler/other/platform_spec.rb | 28 | ||||
-rw-r--r-- | spec/bundler/other/ssl_cert_spec.rb | 18 |
7 files changed, 371 insertions, 321 deletions
diff --git a/spec/bundler/other/bundle_ruby_spec.rb b/spec/bundler/other/bundle_ruby_spec.rb deleted file mode 100644 index fbca31d0a0..0000000000 --- a/spec/bundler/other/bundle_ruby_spec.rb +++ /dev/null @@ -1,155 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe "bundle_ruby", :bundler => "< 3" do - context "without patchlevel" do - it "returns the ruby version" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.9.3", :engine => 'ruby', :engine_version => '1.9.3' - - gem "foo" - G - - bundle_ruby - - expect(out).to include("ruby 1.9.3") - end - - it "engine defaults to MRI" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.9.3" - - gem "foo" - G - - bundle_ruby - - expect(out).to include("ruby 1.9.3") - end - - it "handles jruby" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.8.7", :engine => 'jruby', :engine_version => '1.6.5' - - gem "foo" - G - - bundle_ruby - - expect(out).to include("ruby 1.8.7 (jruby 1.6.5)") - end - - it "handles rbx" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.8.7", :engine => 'rbx', :engine_version => '1.2.4' - - gem "foo" - G - - bundle_ruby - - expect(out).to include("ruby 1.8.7 (rbx 1.2.4)") - end - - it "handles truffleruby", :rubygems => ">= 2.1.0" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "2.5.1", :engine => 'truffleruby', :engine_version => '1.0.0-rc6' - - gem "foo" - G - - bundle_ruby - - expect(out).to include("ruby 2.5.1 (truffleruby 1.0.0-rc6)") - end - - it "raises an error if engine is used but engine version is not" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.8.7", :engine => 'rbx' - - gem "foo" - G - - bundle_ruby - expect(exitstatus).not_to eq(0) if exitstatus - - bundle_ruby - expect(out).to include("Please define :engine_version") - end - - it "raises an error if engine_version is used but engine is not" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.8.7", :engine_version => '1.2.4' - - gem "foo" - G - - bundle_ruby - expect(exitstatus).not_to eq(0) if exitstatus - - bundle_ruby - expect(out).to include("Please define :engine") - end - - it "raises an error if engine version doesn't match ruby version for MRI" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.8.7", :engine => 'ruby', :engine_version => '1.2.4' - - gem "foo" - G - - bundle_ruby - expect(exitstatus).not_to eq(0) if exitstatus - - bundle_ruby - expect(out).to include("ruby_version must match the :engine_version for MRI") - end - - it "should print if no ruby version is specified" do - gemfile <<-G - source "file://#{gem_repo1}" - - gem "foo" - G - - bundle_ruby - - expect(out).to include("No ruby version specified") - end - end - - context "when using patchlevel" do - it "returns the ruby version" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.9.3", :patchlevel => '429', :engine => 'ruby', :engine_version => '1.9.3' - - gem "foo" - G - - bundle_ruby - - expect(out).to include("ruby 1.9.3p429") - end - - it "handles an engine" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.9.3", :patchlevel => '392', :engine => 'jruby', :engine_version => '1.7.4' - - gem "foo" - G - - bundle_ruby - - expect(out).to include("ruby 1.9.3p392 (jruby 1.7.4)") - end - end -end diff --git a/spec/bundler/other/cli_dispatch_spec.rb b/spec/bundler/other/cli_dispatch_spec.rb index d17819b394..67127fc6e0 100644 --- a/spec/bundler/other/cli_dispatch_spec.rb +++ b/spec/bundler/other/cli_dispatch_spec.rb @@ -19,7 +19,7 @@ RSpec.describe "bundle command names" do end context "when cache_command_is_package is set" do - before { bundle! "config cache_command_is_package true" } + before { bundle! "config set cache_command_is_package true" } it "dispatches `bundle cache` to the package command" do bundle "cache --verbose" diff --git a/spec/bundler/other/compatibility_guard_spec.rb b/spec/bundler/other/compatibility_guard_spec.rb index ac05ebd918..c72842eab5 100644 --- a/spec/bundler/other/compatibility_guard_spec.rb +++ b/spec/bundler/other/compatibility_guard_spec.rb @@ -12,14 +12,5 @@ RSpec.describe "bundler compatibility guard" do expect(err).to eq("Bundler 2 requires Ruby 2.3 or later. Either install bundler 1 or update to a supported Ruby version.") end end - - context "when running on RubyGems < 2.5", :ruby => ">= 2.5" do - before { simulate_rubygems_version "1.3.6" } - - it "raises a friendly error" do - bundle :version - expect(err).to eq("Bundler 2 requires RubyGems 2.5 or later. Either install bundler 1 or update to a supported RubyGems version.") - end - end end end diff --git a/spec/bundler/other/ext_spec.rb b/spec/bundler/other/ext_spec.rb index 3f6f8b4928..bc8c781c5d 100644 --- a/spec/bundler/other/ext_spec.rb +++ b/spec/bundler/other/ext_spec.rb @@ -54,13 +54,8 @@ RSpec.describe "Gem::SourceIndex#refresh!" do G end - it "does not explode when called", :rubygems => "1.7" do + it "does not explode when called" do run "Gem.source_index.refresh!" run "Gem::SourceIndex.new([]).refresh!" end - - it "does not explode when called", :rubygems => "< 1.7" do - run "Gem.source_index.refresh!" - run "Gem::SourceIndex.from_gems_in([]).refresh!" - end end diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb index 50800dbb0c..83944e4075 100644 --- a/spec/bundler/other/major_deprecation_spec.rb +++ b/spec/bundler/other/major_deprecation_spec.rb @@ -1,126 +1,235 @@ # frozen_string_literal: true -RSpec.describe "major deprecations", :bundler => "< 3" do - let(:warnings) { last_command.bundler_err } # change to err in 2.0 - let(:warnings_without_version_messages) { warnings.gsub(/#{Spec::Matchers::MAJOR_DEPRECATION}Bundler will only support ruby(gems)? >= .*/, "") } +RSpec.describe "major deprecations" do + let(:warnings) { err } - context "in a .99 version" do + describe "Bundler" do before do - simulate_bundler_version "1.99.1" - bundle "config --delete major_deprecations" + install_gemfile! <<-G + source "file:#{gem_repo1}" + gem "rack" + G end - it "prints major deprecations without being configured" do - ruby <<-R - require "bundler" - Bundler::SharedHelpers.major_deprecation(Bundler::VERSION) - R + describe ".clean_env" do + before do + source = "Bundler.clean_env" + bundle "exec ruby -e #{source.dump}" + end + + it "is deprecated in favor of .unbundled_env", :bundler => "2" do + expect(deprecations).to include \ + "`Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \ + "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`" + end - expect(warnings).to have_major_deprecation("1.99.1") + pending "is removed and shows a helpful error message about it", :bundler => "3" end - end - before do - bundle "config major_deprecations true" + describe ".with_clean_env" do + before do + source = "Bundler.with_clean_env {}" + bundle "exec ruby -e #{source.dump}" + end - create_file "gems.rb", <<-G - source "file:#{gem_repo1}" - ruby #{RUBY_VERSION.dump} - gem "rack" - G - bundle! "install" - end + it "is deprecated in favor of .unbundled_env", :bundler => "2" do + expect(deprecations).to include( + "`Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \ + "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`" + ) + end - describe "bundle_ruby" do - it "prints a deprecation" do - bundle_ruby - warnings.gsub! "\nruby #{RUBY_VERSION}", "" - expect(warnings).to have_major_deprecation "the bundle_ruby executable has been removed in favor of `bundle platform --ruby`" + pending "is removed and shows a helpful error message about it", :bundler => "3" end - end - describe "Bundler" do - describe ".clean_env" do - it "is deprecated in favor of .original_env" do - source = "Bundler.clean_env" + describe ".clean_system" do + before do + source = "Bundler.clean_system('ls')" bundle "exec ruby -e #{source.dump}" - expect(warnings).to have_major_deprecation "`Bundler.clean_env` has weird edge cases, use `.original_env` instead" end + + it "is deprecated in favor of .unbundled_system", :bundler => "2" do + expect(deprecations).to include( + "`Bundler.clean_system` has been deprecated in favor of `Bundler.unbundled_system`. " \ + "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`" + ) + end + + pending "is removed and shows a helpful error message about it", :bundler => "3" + end + + describe ".clean_exec" do + before do + source = "Bundler.clean_exec('ls')" + bundle "exec ruby -e #{source.dump}" + end + + it "is deprecated in favor of .unbundled_exec", :bundler => "2" do + expect(deprecations).to include( + "`Bundler.clean_exec` has been deprecated in favor of `Bundler.unbundled_exec`. " \ + "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`" + ) + end + + pending "is removed and shows a helpful error message about it", :bundler => "3" end describe ".environment" do - it "is deprecated in favor of .load" do + before do source = "Bundler.environment" bundle "exec ruby -e #{source.dump}" - expect(warnings).to have_major_deprecation "Bundler.environment has been removed in favor of Bundler.load" end + + it "is deprecated in favor of .load", :bundler => "2" do + expect(deprecations).to include "Bundler.environment has been removed in favor of Bundler.load" + end + + pending "is removed and shows a helpful error message about it", :bundler => "3" end + end - shared_examples_for "environmental deprecations" do |trigger| - describe "ruby version", :ruby => "< 2.0" do - it "requires a newer ruby version" do - instance_eval(&trigger) - expect(warnings).to have_major_deprecation "Bundler will only support ruby >= 2.0, you are running #{RUBY_VERSION}" - end + describe "bundle update --quiet" do + it "does not print any deprecations" do + bundle :update, :quiet => true + expect(deprecations).to be_empty + end + end + + describe "bundle config" do + describe "old list interface" do + before do + bundle! "config" end - describe "rubygems version", :rubygems => "< 2.0" do - it "requires a newer rubygems version" do - instance_eval(&trigger) - expect(warnings).to have_major_deprecation "Bundler will only support rubygems >= 2.0, you are running #{Gem::VERSION}" - end + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config list` instead.") end + + pending "fails with a helpful error", :bundler => "3" end - describe "-rbundler/setup" do - it_behaves_like "environmental deprecations", proc { ruby "require 'bundler/setup'" } + describe "old get interface" do + before do + bundle! "config waka" + end + + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config get waka` instead.") + end + + pending "fails with a helpful error", :bundler => "3" end - describe "Bundler.setup" do - it_behaves_like "environmental deprecations", proc { ruby "require 'bundler'; Bundler.setup" } + describe "old set interface" do + before do + bundle! "config waka wakapun" + end + + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set waka wakapun` instead.") + end + + pending "fails with a helpful error", :bundler => "3" end - describe "bundle check" do - it_behaves_like "environmental deprecations", proc { bundle :check } + describe "old set interface with --local" do + before do + bundle! "config --local waka wakapun" + end + + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set --local waka wakapun` instead.") + end + + pending "fails with a helpful error", :bundler => "3" end - describe "bundle update --quiet" do - it "does not print any deprecations" do - bundle :update, :quiet => true - expect(warnings_without_version_messages).not_to have_major_deprecation + describe "old set interface with --global" do + before do + bundle! "config --global waka wakapun" end + + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set --global waka wakapun` instead.") + end + + pending "fails with a helpful error", :bundler => "3" end - describe "bundle update" do + describe "old unset interface" do before do - create_file("gems.rb", "") - bundle! "install" + bundle! "config --delete waka" end - it "warns when no options are given" do - bundle! "update" - expect(warnings).to have_major_deprecation a_string_including("Pass --all to `bundle update` to update everything") + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset waka` instead.") end - it "does not warn when --all is passed" do - bundle! "update --all" - expect(warnings_without_version_messages).not_to have_major_deprecation + pending "fails with a helpful error", :bundler => "3" + end + + describe "old unset interface with --local" do + before do + bundle! "config --delete --local waka" + end + + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset --local waka` instead.") end + + pending "fails with a helpful error", :bundler => "3" end - describe "bundle install --binstubs" do - it "should output a deprecation warning" do - gemfile <<-G - gem 'rack' - G + describe "old unset interface with --global" do + before do + bundle! "config --delete --global waka" + end - bundle :install, :binstubs => true - expect(warnings).to have_major_deprecation a_string_including("The --binstubs option will be removed") + it "warns", :bundler => "2" do + expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset --global waka` instead.") end + + pending "fails with a helpful error", :bundler => "3" + end + end + + describe "bundle update" do + before do + install_gemfile <<-G + source "file:#{gem_repo1}" + gem "rack" + G + end + + it "warns when no options are given", :bundler => "2" do + bundle! "update" + expect(deprecations).to include("Pass --all to `bundle update` to update everything") + end + + pending "fails with a helpful error when no options are given", :bundler => "3" + + it "does not warn when --all is passed" do + bundle! "update --all" + expect(deprecations).to be_empty + end + end + + describe "bundle install --binstubs" do + before do + install_gemfile <<-G, :binstubs => true + source "file:#{gem_repo1}" + gem "rack" + G + end + + it "should output a deprecation warning", :bundler => "2" do + expect(deprecations).to include("The --binstubs option will be removed in favor of `bundle binstubs`") end + + pending "fails with a helpful error", :bundler => "3" end - context "when bundle is run" do + context "bundle install with both gems.rb and Gemfile present" do it "should not warn about gems.rb" do create_file "gems.rb", <<-G source "file://#{gem_repo1}" @@ -128,36 +237,92 @@ RSpec.describe "major deprecations", :bundler => "< 3" do G bundle :install - expect(warnings_without_version_messages).not_to have_major_deprecation + expect(deprecations).to be_empty end - it "should print a Gemfile deprecation warning" do + it "should print a proper warning, and use gems.rb" do create_file "gems.rb" install_gemfile! <<-G source "file://#{gem_repo1}" gem "rack" G - expect(the_bundle).to include_gem "rack 1.0" - expect(warnings).to have_major_deprecation a_string_including("gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock.") + expect(warnings).to include( + "Multiple gemfiles (gems.rb and Gemfile) detected. Make sure you remove Gemfile and Gemfile.lock since bundler is ignoring them in favor of gems.rb and gems.rb.locked." + ) + + expect(the_bundle).not_to include_gem "rack 1.0" end + end - context "with flags" do - it "should print a deprecation warning about autoremembering flags" do - install_gemfile <<-G, :path => "vendor/bundle" - source "file://#{gem_repo1}" - gem "rack" - G + context "bundle install with flags" do + before do + bundle "config set --local path vendor/bundle" - expect(warnings).to have_major_deprecation a_string_including( - "flags passed to commands will no longer be automatically remembered." - ) + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G + end + + { + :clean => true, + :deployment => true, + :frozen => true, + :"no-cache" => true, + :"no-prune" => true, + :path => "vendor/bundle", + :shebang => "ruby27", + :system => true, + :without => "development", + :with => "development", + }.each do |name, value| + flag_name = "--#{name}" + + context "with the #{flag_name} flag" do + before do + bundle "install" # to create a lockfile, which deployment or frozen need + bundle "install #{flag_name} #{value}" + end + + it "should print a deprecation warning", :bundler => "2" do + expect(deprecations).to include( + "The `#{flag_name}` flag is deprecated because it relies on " \ + "being remembered accross bundler invokations, which bundler " \ + "will no longer do in future versions. Instead please use " \ + "`bundle config #{name} '#{value}'`, and stop using this flag" + ) + end + + pending "should fail with a helpful error", :bundler => "3" end end end + context "bundle install with multiple sources" do + before do + install_gemfile <<-G + source "file://localhost#{gem_repo3}" + source "file://localhost#{gem_repo1}" + G + end + + it "shows a deprecation", :bundler => "2" do + expect(deprecations).to include( + "Your Gemfile contains multiple primary sources. " \ + "Using `source` more than once without a block is a security risk, and " \ + "may result in installing unexpected gems. To resolve this warning, use " \ + "a block to indicate which gems should come from the secondary source. " \ + "To upgrade this warning to an error, run `bundle config set " \ + "disable_multisource true`." + ) + end + + pending "should fail with a helpful error", :bundler => "3" + end + context "when Bundler.setup is run in a ruby script" do - it "should print a single deprecation warning" do + before do create_file "gems.rb" install_gemfile! <<-G source "file://#{gem_repo1}" @@ -173,52 +338,57 @@ RSpec.describe "major deprecations", :bundler => "< 3" do Bundler.setup Bundler.setup RUBY + end - expect(warnings_without_version_messages).to have_major_deprecation("gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock.") + it "should print a single deprecation warning" do + expect(warnings).to include( + "Multiple gemfiles (gems.rb and Gemfile) detected. Make sure you remove Gemfile and Gemfile.lock since bundler is ignoring them in favor of gems.rb and gems.rb.locked." + ) end end context "when `bundler/deployment` is required in a ruby script" do - it "should print a capistrano deprecation warning" do + before do ruby(<<-RUBY) require 'bundler/deployment' RUBY + end - expect(warnings).to have_major_deprecation("Bundler no longer integrates " \ + it "should print a capistrano deprecation warning", :bundler => "2" do + expect(deprecations).to include("Bundler no longer integrates " \ "with Capistrano, but Capistrano provides " \ "its own integration with Bundler via the " \ "capistrano-bundler gem. Use it instead.") end + + pending "should fail with a helpful error", :bundler => "3" end describe Bundler::Dsl do + let(:msg) do + <<-EOS +The :github git source is deprecated, and will be removed in the future. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work: + + git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" } + + EOS + end + before do @rubygems = double("rubygems") allow(Bundler::Source::Rubygems).to receive(:new) { @rubygems } end context "with github gems" do - it "warns about the https change" do - msg = <<-EOS -The :github git source is deprecated, and will be removed in Bundler 3.0. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work: - - git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" } - - EOS + it "warns about the https change if people are opting out" do + Bundler.settings.temporary "github.https" => false expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg) + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, "Setting `github.https` to false is deprecated and won't be supported in the future.") subject.gem("sparks", :github => "indirect/sparks") end - it "upgrades to https on request" do - Bundler.settings.temporary "github.https" => true - msg = <<-EOS -The :github git source is deprecated, and will be removed in Bundler 3.0. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work: - - git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" } - - EOS + it "upgrades to https by default", :bundler => "2" do expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg) - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, "The `github.https` setting will be removed") subject.gem("sparks", :github => "indirect/sparks") github_uri = "https://github.com/indirect/sparks.git" expect(subject.dependencies.first.source.uri).to eq(github_uri) @@ -229,7 +399,7 @@ The :github git source is deprecated, and will be removed in Bundler 3.0. Change it "warns about removal" do allow(Bundler.ui).to receive(:deprecate) msg = <<-EOS -The :bitbucket git source is deprecated, and will be removed in Bundler 3.0. Add this code to the top of your Gemfile to ensure it continues to work: +The :bitbucket git source is deprecated, and will be removed in the future. Add this code to the top of your Gemfile to ensure it continues to work: git_source(:bitbucket) do |repo_name| user_name, repo_name = repo_name.split("/") @@ -246,10 +416,12 @@ The :bitbucket git source is deprecated, and will be removed in Bundler 3.0. Add context "with gist gems" do it "warns about removal" do allow(Bundler.ui).to receive(:deprecate) - msg = "The :gist git source is deprecated, and will be removed " \ - "in Bundler 3.0. Add this code to the top of your Gemfile to ensure it " \ - "continues to work:\n\n git_source(:gist) {|repo_name| " \ - "\"https://gist.github.com/\#{repo_name}.git\" }\n\n" + msg = <<-EOS +The :gist git source is deprecated, and will be removed in the future. Add this code to the top of your Gemfile to ensure it continues to work: + + git_source(:gist) {|repo_name| "https://gist.github.com/\#{repo_name}.git" } + + EOS expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg) subject.gem("not-really-a-gem", :gist => "1234") end @@ -257,26 +429,91 @@ The :bitbucket git source is deprecated, and will be removed in Bundler 3.0. Add end context "bundle show" do - it "prints a deprecation warning" do + before do install_gemfile! <<-G source "file://#{gem_repo1}" gem "rack" G + end - bundle! :show + context "without flags" do + before do + bundle! :show + end - warnings.gsub!(/gems included.*?\[DEPRECATED/im, "[DEPRECATED") + it "prints a deprecation warning recommending `bundle list`", :bundler => "2" do + expect(deprecations).to include("use `bundle list` instead of `bundle show`") + end - expect(warnings).to have_major_deprecation a_string_including("use `bundle list` instead of `bundle show`") + pending "fails with a helpful message", :bundler => "3" end + + context "with --outdated flag" do + before do + bundle! "show --outdated" + end + + it "prints a deprecation warning informing about its removal", :bundler => "2" do + expect(deprecations).to include("the `--outdated` flag to `bundle show` was undocumented and will be removed without replacement") + end + + pending "fails with a helpful message", :bundler => "3" + end + + context "with --verbose flag" do + before do + bundle! "show --verbose" + end + + it "prints a deprecation warning informing about its removal", :bundler => "2" do + expect(deprecations).to include("the `--verbose` flag to `bundle show` was undocumented and will be removed without replacement") + end + + pending "fails with a helpful message", :bundler => "3" + end + + context "with a gem argument" do + before do + bundle! "show rack" + end + + it "prints a deprecation warning recommending `bundle info`", :bundler => "2" do + expect(deprecations).to include("use `bundle info rack` instead of `bundle show rack`") + end + end + + pending "fails with a helpful message", :bundler => "3" end context "bundle console" do - it "prints a deprecation warning" do + before do bundle "console" + end - expect(warnings).to have_major_deprecation \ - a_string_including("bundle console will be replaced by `bin/console` generated by `bundle gem <name>`") + it "prints a deprecation warning", :bundler => "2" do + expect(deprecations).to include \ + "bundle console will be replaced by `bin/console` generated by `bundle gem <name>`" end + + pending "fails with a helpful message", :bundler => "3" + end + + context "bundle viz" do + let(:ruby_graphviz) do + graphviz_glob = base_system_gems.join("cache/ruby-graphviz*") + Pathname.glob(graphviz_glob).first + end + + before do + system_gems ruby_graphviz + create_file "gems.rb" + bundle "viz" + end + + it "prints a deprecation warning", :bundler => "2" do + expect(deprecations).to include "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz" + end + + pending "fails with a helpful message", :bundler => "3" end end diff --git a/spec/bundler/other/platform_spec.rb b/spec/bundler/other/platform_spec.rb index 6c59fd893c..9c62904286 100644 --- a/spec/bundler/other/platform_spec.rb +++ b/spec/bundler/other/platform_spec.rb @@ -149,7 +149,7 @@ G expect(out).to eq("ruby 1.8.7 (rbx 1.2.4)") end - it "handles truffleruby", :rubygems => ">= 2.1.0" do + it "handles truffleruby" do gemfile <<-G source "file://#{gem_repo1}" ruby "2.5.1", :engine => 'truffleruby', :engine_version => '1.0.0-rc6' @@ -268,27 +268,27 @@ G def should_be_ruby_version_incorrect expect(exitstatus).to eq(18) if exitstatus - expect(out).to be_include("Your Ruby version is #{RUBY_VERSION}, but your Gemfile specified #{not_local_ruby_version}") + expect(err).to be_include("Your Ruby version is #{RUBY_VERSION}, but your Gemfile specified #{not_local_ruby_version}") end def should_be_engine_incorrect expect(exitstatus).to eq(18) if exitstatus - expect(out).to be_include("Your Ruby engine is #{local_ruby_engine}, but your Gemfile specified #{not_local_tag}") + expect(err).to be_include("Your Ruby engine is #{local_ruby_engine}, but your Gemfile specified #{not_local_tag}") end def should_be_engine_version_incorrect expect(exitstatus).to eq(18) if exitstatus - expect(out).to be_include("Your #{local_ruby_engine} version is #{local_engine_version}, but your Gemfile specified #{local_ruby_engine} #{not_local_engine_version}") + expect(err).to be_include("Your #{local_ruby_engine} version is #{local_engine_version}, but your Gemfile specified #{local_ruby_engine} #{not_local_engine_version}") end def should_be_patchlevel_incorrect expect(exitstatus).to eq(18) if exitstatus - expect(out).to be_include("Your Ruby patchlevel is #{RUBY_PATCHLEVEL}, but your Gemfile specified #{not_local_patchlevel}") + expect(err).to be_include("Your Ruby patchlevel is #{RUBY_PATCHLEVEL}, but your Gemfile specified #{not_local_patchlevel}") end def should_be_patchlevel_fixnum expect(exitstatus).to eq(18) if exitstatus - expect(out).to be_include("The Ruby patchlevel in your Gemfile must be a string") + expect(err).to be_include("The Ruby patchlevel in your Gemfile must be a string") end context "bundle install" do @@ -511,7 +511,7 @@ G build_gem "activesupport", "3.0" end - bundle "update", :all => bundle_update_requires_all? + bundle "update", :all => true expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0" end @@ -528,7 +528,7 @@ G build_gem "activesupport", "3.0" end - bundle "update", :all => bundle_update_requires_all? + bundle "update", :all => true expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0" end end @@ -545,7 +545,7 @@ G build_gem "activesupport", "3.0" end - bundle :update, :all => bundle_update_requires_all? + bundle :update, :all => true should_be_ruby_version_incorrect end @@ -561,7 +561,7 @@ G build_gem "activesupport", "3.0" end - bundle :update, :all => bundle_update_requires_all? + bundle :update, :all => true should_be_engine_incorrect end @@ -578,7 +578,7 @@ G build_gem "activesupport", "3.0" end - bundle :update, :all => bundle_update_requires_all? + bundle :update, :all => true should_be_engine_version_incorrect end end @@ -594,7 +594,7 @@ G build_gem "activesupport", "3.0" end - bundle :update, :all => bundle_update_requires_all? + bundle :update, :all => true should_be_patchlevel_incorrect end end @@ -863,7 +863,7 @@ G G bundle "exec rackup" - expect(out).to eq("0.9.1") + expect(out).to include("0.9.1") end it "activates the correct gem when ruby version matches any engine" do @@ -876,7 +876,7 @@ G G bundle "exec rackup" - expect(out).to eq("0.9.1") + expect(out).to include("0.9.1") end end diff --git a/spec/bundler/other/ssl_cert_spec.rb b/spec/bundler/other/ssl_cert_spec.rb deleted file mode 100644 index 6d957276fc..0000000000 --- a/spec/bundler/other/ssl_cert_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require "bundler/ssl_certs/certificate_manager" - -RSpec.describe "SSL Certificates", :rubygems_master do - hosts = %w[ - rubygems.org - index.rubygems.org - rubygems.global.ssl.fastly.net - staging.rubygems.org - ] - - hosts.each do |host| - it "can securely connect to #{host}", :realworld do - Bundler::SSLCerts::CertificateManager.new.connect_to(host) - end - end -end |