diff options
Diffstat (limited to 'spec/bundler/other')
| -rw-r--r-- | spec/bundler/other/bundle_ruby_spec.rb | 142 | ||||
| -rw-r--r-- | spec/bundler/other/cli_dispatch_spec.rb | 25 | ||||
| -rw-r--r-- | spec/bundler/other/cli_man_pages_spec.rb | 100 | ||||
| -rw-r--r-- | spec/bundler/other/compatibility_guard_spec.rb | 25 | ||||
| -rw-r--r-- | spec/bundler/other/ext_spec.rb | 70 | ||||
| -rw-r--r-- | spec/bundler/other/major_deprecation_spec.rb | 846 | ||||
| -rw-r--r-- | spec/bundler/other/platform_spec.rb | 1299 | ||||
| -rw-r--r-- | spec/bundler/other/ssl_cert_spec.rb | 18 |
8 files changed, 816 insertions, 1709 deletions
diff --git a/spec/bundler/other/bundle_ruby_spec.rb b/spec/bundler/other/bundle_ruby_spec.rb deleted file mode 100644 index 6cc33f60ac..0000000000 --- a/spec/bundler/other/bundle_ruby_spec.rb +++ /dev/null @@ -1,142 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe "bundle_ruby", :bundler => "< 2" 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 "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 a9d0bf7462..a2c745b070 100644 --- a/spec/bundler/other/cli_dispatch_spec.rb +++ b/spec/bundler/other/cli_dispatch_spec.rb @@ -2,28 +2,19 @@ RSpec.describe "bundle command names" do it "work when given fully" do - bundle "install" - expect(last_command.bundler_err).to eq("Could not locate Gemfile") - expect(last_command.stdboth).not_to include("Ambiguous command") + bundle "install", raise_on_error: false + expect(err).to eq("Could not locate Gemfile") + expect(stdboth).not_to include("Ambiguous command") end it "work when not ambiguous" do - bundle "ins" - expect(last_command.bundler_err).to eq("Could not locate Gemfile") - expect(last_command.stdboth).not_to include("Ambiguous command") + bundle "ins", raise_on_error: false + expect(err).to eq("Could not locate Gemfile") + expect(stdboth).not_to include("Ambiguous command") end it "print a friendly error when ambiguous" do - bundle "in" - expect(last_command.bundler_err).to eq("Ambiguous command in matches [info, init, inject, install]") - end - - context "when cache_command_is_package is set" do - before { bundle! "config cache_command_is_package true" } - - it "dispatches `bundle cache` to the package command" do - bundle "cache --verbose" - expect(last_command.stdout).to start_with "Running `bundle package --no-color --verbose`" - end + bundle "in", raise_on_error: false + expect(err).to eq("Ambiguous command in matches [info, init, install]") end end diff --git a/spec/bundler/other/cli_man_pages_spec.rb b/spec/bundler/other/cli_man_pages_spec.rb new file mode 100644 index 0000000000..4e8f155309 --- /dev/null +++ b/spec/bundler/other/cli_man_pages_spec.rb @@ -0,0 +1,100 @@ +# frozen_string_literal: true + +RSpec.describe "bundle commands" do + it "expects all commands to have all options and subcommands documented" do + check_commands!(Bundler::CLI) + + Bundler::CLI.subcommand_classes.each_value do |klass| + check_commands!(klass) + end + end + + private + + def check_commands!(command_class) + command_class.commands.each do |command_name, command| + if command.is_a?(Bundler::Thor::HiddenCommand) + man_page = man_page(command_name) + expect(man_page).not_to exist + expect(main_man_page.read).not_to include("bundle #{command_name}") + elsif command_class == Bundler::CLI + man_page = man_page(command_name) + expect(man_page).to exist + + check_options!(command, man_page) + else + man_page = man_page(command.ancestor_name) + expect(man_page).to exist + + check_options!(command, man_page) + check_subcommand!(command_name, man_page) + end + end + end + + def check_options!(command, man_page) + command.options.each do |_, option| + check_option!(option, man_page) + end + end + + def check_option!(option, man_page) + man_page_content = man_page.read + + aliases = option.aliases + formatted_aliases = aliases.sort.map {|name| "`#{name}`" }.join(", ") if aliases + + help = if option.type == :boolean + "* #{append_aliases("`#{option.switch_name}`", formatted_aliases)}:" + elsif option.enum + formatted_aliases = "`#{option.switch_name}`" if aliases.empty? && option.lazy_default + "* #{prepend_aliases(option.enum.sort.map {|enum| "`#{option.switch_name}=#{enum}`" }.join(", "), formatted_aliases)}:" + else + names = [option.switch_name, *aliases] + value = + case option.type + when :array then "<list>" + when :numeric then "<number>" + else option.name.upcase + end + + value = option.type != :numeric && option.lazy_default ? "[=#{value}]" : "=#{value}" + + "* #{names.map {|name| "`#{name}#{value}`" }.join(", ")}:" + end + + if option.banner.include?("(removed)") + expect(man_page_content).not_to include(help) + else + expect(man_page_content).to include(help) + end + end + + def check_subcommand!(name, man_page) + expect(man_page.read).to match(name) + end + + def append_aliases(text, aliases) + return text if aliases.empty? + + "#{text}, #{aliases}" + end + + def prepend_aliases(text, aliases) + return text if aliases.empty? + + "#{aliases}, #{text}" + end + + def man_page_content(command_name) + man_page(command_name).read + end + + def man_page(command_name) + source_root.join("lib/bundler/man/bundle-#{command_name}.1.ronn") + end + + def main_man_page + source_root.join("lib/bundler/man/bundle.1.ronn") + end +end diff --git a/spec/bundler/other/compatibility_guard_spec.rb b/spec/bundler/other/compatibility_guard_spec.rb deleted file mode 100644 index ac05ebd918..0000000000 --- a/spec/bundler/other/compatibility_guard_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe "bundler compatibility guard" do - context "when the bundler version is 2+" do - before { simulate_bundler_version "2.0.a" } - - context "when running on Ruby < 2.3", :ruby => "< 2.3" do - before { simulate_rubygems_version "2.6.11" } - - it "raises a friendly error" do - bundle :version - 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..a883eefe06 100644 --- a/spec/bundler/other/ext_spec.rb +++ b/spec/bundler/other/ext_spec.rb @@ -1,66 +1,50 @@ # frozen_string_literal: true -RSpec.describe "Gem::Specification#match_platform" do +RSpec.describe "Gem::Specification#installable_on_platform?" do it "does not match platforms other than the gem platform" do darwin = gem "lol", "1.0", "platform_specific-1.0-x86-darwin-10" - expect(darwin.match_platform(pl("java"))).to eq(false) + expect(darwin.installable_on_platform?(pl("java"))).to eq(false) end context "when platform is a string" do it "matches when platform is a string" do lazy_spec = Bundler::LazySpecification.new("lol", "1.0", "universal-mingw32") - expect(lazy_spec.match_platform(pl("x86-mingw32"))).to eq(true) - expect(lazy_spec.match_platform(pl("x64-mingw32"))).to eq(true) + expect(lazy_spec.installable_on_platform?(pl("x86-mingw32"))).to eq(true) + expect(lazy_spec.installable_on_platform?(pl("x64-mingw32"))).to eq(true) end end end -RSpec.describe "Bundler::GemHelpers#generic" do - include Bundler::GemHelpers - - it "converts non-windows platforms into ruby" do - expect(generic(pl("x86-darwin-10"))).to eq(pl("ruby")) - expect(generic(pl("ruby"))).to eq(pl("ruby")) - end - - it "converts java platform variants into java" do - expect(generic(pl("universal-java-17"))).to eq(pl("java")) - expect(generic(pl("java"))).to eq(pl("java")) - end - - it "converts mswin platform variants into x86-mswin32" do - expect(generic(pl("mswin32"))).to eq(pl("x86-mswin32")) - expect(generic(pl("i386-mswin32"))).to eq(pl("x86-mswin32")) - expect(generic(pl("x86-mswin32"))).to eq(pl("x86-mswin32")) - end - - it "converts 32-bit mingw platform variants into x86-mingw32" do - expect(generic(pl("mingw32"))).to eq(pl("x86-mingw32")) - expect(generic(pl("i386-mingw32"))).to eq(pl("x86-mingw32")) - expect(generic(pl("x86-mingw32"))).to eq(pl("x86-mingw32")) - end - - it "converts 64-bit mingw platform variants into x64-mingw32" do - expect(generic(pl("x64-mingw32"))).to eq(pl("x64-mingw32")) - expect(generic(pl("x86_64-mingw32"))).to eq(pl("x64-mingw32")) - end -end - RSpec.describe "Gem::SourceIndex#refresh!" do before do install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" + source "https://gem.repo1" + gem "myrack" G end - it "does not explode when called", :rubygems => "1.7" do - run "Gem.source_index.refresh!" - run "Gem::SourceIndex.new([]).refresh!" + it "does not explode when called" do + run "Gem.source_index.refresh!", raise_on_error: false + run "Gem::SourceIndex.new([]).refresh!", raise_on_error: false + end +end + +RSpec.describe "Gem::NameTuple" do + describe "#initialize" do + it "creates a Gem::NameTuple with equality regardless of platform type" do + gem_platform = Gem::NameTuple.new "a", v("1"), pl("x86_64-linux") + str_platform = Gem::NameTuple.new "a", v("1"), "x86_64-linux" + expect(gem_platform).to eq(str_platform) + expect(gem_platform.hash).to eq(str_platform.hash) + expect(gem_platform.to_a).to eq(str_platform.to_a) + end end - it "does not explode when called", :rubygems => "< 1.7" do - run "Gem.source_index.refresh!" - run "Gem::SourceIndex.from_gems_in([]).refresh!" + describe "#lock_name" do + it "returns the lock name" do + expect(Gem::NameTuple.new("a", v("1.0.0"), pl("x86_64-linux")).lock_name).to eq("a (1.0.0-x86_64-linux)") + expect(Gem::NameTuple.new("a", v("1.0.0"), "ruby").lock_name).to eq("a (1.0.0)") + expect(Gem::NameTuple.new("a", v("1.0.0")).lock_name).to eq("a (1.0.0)") + end end end diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb index fba177b497..ab7589d698 100644 --- a/spec/bundler/other/major_deprecation_spec.rb +++ b/spec/bundler/other/major_deprecation_spec.rb @@ -1,282 +1,798 @@ # frozen_string_literal: true -RSpec.describe "major deprecations", :bundler => "< 2" 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 "https://gem.repo1" + gem "myrack" + 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}", raise_on_error: false + end - expect(warnings).to have_major_deprecation("1.99.1") + it "is removed in favor of .unbundled_env and shows a helpful error message about it" do + expect(err).to include \ + "`Bundler.clean_env` has been removed in favor of `Bundler.unbundled_env`. " \ + "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`" \ + end 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}", raise_on_error: false + end - create_file "gems.rb", <<-G - source "file:#{gem_repo1}" - ruby #{RUBY_VERSION.dump} - gem "rack" - G - bundle! "install" - end + it "is removed in favor of .unbundled_env and shows a helpful error message about it" do + expect(err).to include( + "`Bundler.with_clean_env` has been removed in favor of `Bundler.with_unbundled_env`. " \ + "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`" + ) + end + end + + describe ".clean_system" do + before do + source = "Bundler.clean_system('ls')" + bundle "exec ruby -e #{source.dump}", raise_on_error: false + 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`" + it "is removed in favor of .unbundled_system and shows a helpful error message about it" do + expect(err).to include( + "`Bundler.clean_system` has been removed 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 end - end - describe "Bundler" do - describe ".clean_env" do - it "is deprecated in favor of .original_env" do - source = "Bundler.clean_env" - bundle "exec ruby -e #{source.dump}" - expect(warnings).to have_major_deprecation "`Bundler.clean_env` has weird edge cases, use `.original_env` instead" + describe ".clean_exec" do + before do + source = "Bundler.clean_exec('ls')" + bundle "exec ruby -e #{source.dump}", raise_on_error: false + end + + it "is removed in favor of .unbundled_exec and shows a helpful error message about it" do + expect(err).to include( + "`Bundler.clean_exec` has been removed 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 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" + bundle "exec ruby -e #{source.dump}", raise_on_error: false + end + + it "is removed in favor of .load and shows a helpful error message about it" do + expect(err).to include "Bundler.environment has been removed in favor of Bundler.load" end 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 exec --no-keep-file-descriptors" do + before do + bundle "exec --no-keep-file-descriptors -e 1", raise_on_error: false + end + + it "is removed and shows a helpful error message about it" do + expect(err).to include "The `--no-keep-file-descriptors` has been removed. `bundle exec` no longer mess with your file descriptors. Close them in the exec'd script if you need to" + end + end + + describe "bundle update --quiet" do + it "does not print any deprecations" do + bundle :update, quiet: true, raise_on_error: false + expect(deprecations).to be_empty + end + end + + context "bundle check --path" do + before do + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack" + G + + bundle "check --path vendor/bundle", raise_on_error: false + end + + it "fails with a helpful error" do + expect(err).to include( + "The `--path` flag has been removed because it relied on being " \ + "remembered across bundler invocations, which bundler no longer " \ + "does. Instead please use `bundle config set path 'vendor/bundle'`, " \ + "and stop using this flag" + ) + end + end + + context "bundle check --path=" do + before do + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack" + G + + bundle "check --path=vendor/bundle", raise_on_error: false + end + + it "fails with a helpful error" do + expect(err).to include( + "The `--path` flag has been removed because it relied on being " \ + "remembered across bundler invocations, which bundler no longer " \ + "does. Instead please use `bundle config set path 'vendor/bundle'`, " \ + "and stop using this flag" + ) + end + end + + context "bundle binstubs --path=" do + before do + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack" + G + + bundle "binstubs myrack --path=binpath", raise_on_error: false + end + + it "fails with a helpful error" do + expect(err).to include( + "The `--path` flag has been removed because it relied on being " \ + "remembered across bundler invocations, which bundler no longer " \ + "does. Instead please use `bundle config set bin 'binpath'`, " \ + "and stop using this flag" + ) + end + end + + context "bundle cache --all" do + before do + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack" + G + + bundle "cache --all --verbose", raise_on_error: false + end + + it "fails with a helpful error" do + expect(err).to include( + "The `--all` flag has been removed because it relied on being " \ + "remembered across bundler invocations, which bundler no longer " \ + "does. Instead please use `bundle config set cache_all true`, " \ + "and stop using this flag" + ) + end + end + + context "bundle cache --no-all" do + before do + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack" + G + + bundle "cache --no-all", raise_on_error: false + end + + it "fails with a helpful error" do + expect(err).to include( + "The `--no-all` flag has been removed because it relied on being " \ + "remembered across bundler invocations, which bundler no longer " \ + "does. Instead please use `bundle config set cache_all false`, " \ + "and stop using this flag" + ) + end + end + + context "bundle cache --path" do + before do + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack" + G + + bundle "cache --path foo", raise_on_error: false + end + + it "should print a removal error" do + expect(err).to include( + "The `--path` flag has been removed because its semantics were unclear. " \ + "Use `bundle config cache_path` to configure the path of your cache of gems, " \ + "and `bundle config path` to configure the path where your gems are installed, " \ + "and stop using this flag" + ) + end + end + + context "bundle cache --path=" do + before do + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack" + G + + bundle "cache --path=foo", raise_on_error: false + end + + it "should print a deprecation warning" do + expect(err).to include( + "The `--path` flag has been removed because its semantics were unclear. " \ + "Use `bundle config cache_path` to configure the path of your cache of gems, " \ + "and `bundle config path` to configure the path where your gems are installed, " \ + "and stop using this flag" + ) + end + end + + context "bundle cache --frozen" do + before do + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack" + G + + bundle "cache --frozen", raise_on_error: false + end + + it "fails with a helpful error" do + expect(err).to include( + "The `--frozen` flag has been removed because it relied on being " \ + "remembered across bundler invocations, which bundler no longer " \ + "does. Instead please use `bundle config set frozen true`, " \ + "and stop using this flag" + ) + end + end + + context "bundle cache --no-prune" do + before do + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack" + G + + bundle "cache --no-prune", raise_on_error: false + end + + it "fails with a helpful error" do + expect(err).to include( + "The `--no-prune` flag has been removed because it relied on being " \ + "remembered across bundler invocations, which bundler no longer " \ + "does. Instead please use `bundle config set no_prune true`, " \ + "and stop using this flag" + ) + 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: "4" 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: "5" 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", raise_on_error: false + end + + it "warns", bundler: "4" 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: "5" 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: "4" 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: "5" 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: "4" 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: "5" 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: "4" 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: "5" 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: "4" 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: "5" + end + + describe "old unset interface with --local" do + before do + bundle "config --delete --local waka" end + + it "warns", bundler: "4" 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: "5" 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: "4" 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: "5" + end + end + + describe "bundle update" do + before do + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack" + G + end + + it "warns when no options are given", bundler: "4" 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: "5" + + it "does not warn when --all is passed" do + bundle "update --all" + expect(deprecations).to be_empty end end - context "when bundle is run" do + describe "bundle install --binstubs" do + before do + install_gemfile <<-G, binstubs: true, raise_on_error: false + source "https://gem.repo1" + gem "myrack" + G + end + + it "fails with a helpful error" do + expect(err).to include("The --binstubs option has been removed in favor of `bundle binstubs --all`") + end + end + + 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}" - gem "rack" + gemfile "gems.rb", <<-G + source "https://gem.repo1" + gem "myrack" 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 - create_file "gems.rb" - install_gemfile! <<-G - source "file://#{gem_repo1}" - gem "rack" + it "should print a proper warning, and use gems.rb" do + gemfile "gems.rb", "source 'https://gem.repo1'" + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack" 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.locked." + ) + + expect(the_bundle).not_to include_gem "myrack 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 "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 "https://gem.repo1" + gem "myrack" + G + end + + { + "clean" => ["clean", "true"], + "deployment" => ["deployment", "true"], + "frozen" => ["frozen", "true"], + "no-deployment" => ["deployment", "false"], + "no-prune" => ["no_prune", "true"], + "path" => ["path", "'vendor/bundle'"], + "shebang" => ["shebang", "'ruby27'"], + "system" => ["path.system", "true"], + "without" => ["without", "'development'"], + "with" => ["with", "'development'"], + }.each do |name, expectations| + option_name, value = *expectations + flag_name = "--#{name}" + args = %w[true false].include?(value) ? flag_name : "#{flag_name} #{value}" + + context "with the #{flag_name} flag" do + before do + bundle "install" # to create a lockfile, which deployment or frozen need + + bundle "install #{args}", raise_on_error: false + end + + it "fails with a helpful error" do + expect(err).to include( + "The `#{flag_name}` flag has been removed because it relied on " \ + "being remembered across bundler invocations, which bundler no " \ + "longer does. Instead please use `bundle config set " \ + "#{option_name} #{value}`, and stop using this flag" + ) + end end end end + context "bundle install with multiple sources" do + before do + install_gemfile <<-G, raise_on_error: false + source "https://gem.repo3" + source "https://gem.repo1" + G + end + + it "fails with a helpful error" do + expect(err).to include( + "This Gemfile contains multiple global sources. " \ + "Each source after the first must include a block to indicate which gems " \ + "should come from that source" + ) + end + + it "doesn't show lockfile deprecations if there's a lockfile" do + lockfile <<~L + GEM + remote: https://gem.repo3/ + remote: https://gem.repo1/ + specs: + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + + BUNDLED WITH + #{Bundler::VERSION} + L + bundle "install", raise_on_error: false + + expect(err).to include( + "This Gemfile contains multiple global sources. " \ + "Each source after the first must include a block to indicate which gems " \ + "should come from that source" + ) + expect(err).not_to include( + "Your lockfile contains a single rubygems source section with multiple remotes, which is insecure. " \ + "Make sure you run `bundle install` in non frozen mode and commit the result to make your lockfile secure." + ) + bundle_config "frozen true" + bundle "install", raise_on_error: false + + expect(err).to include( + "This Gemfile contains multiple global sources. " \ + "Each source after the first must include a block to indicate which gems " \ + "should come from that source" + ) + expect(err).not_to include( + "Your lockfile contains a single rubygems source section with multiple remotes, which is insecure. " \ + "Make sure you run `bundle install` in non frozen mode and commit the result to make your lockfile secure." + ) + end + end + + context "bundle install with a lockfile with a single rubygems section with multiple remotes" do + before do + build_repo3 do + build_gem "myrack", "0.9.1" + end + + gemfile <<-G + source "https://gem.repo1" + source "https://gem.repo3" do + gem 'myrack' + end + G + + lockfile <<~L + GEM + remote: https://gem.repo1/ + remote: https://gem.repo3/ + specs: + myrack (0.9.1) + + PLATFORMS + ruby + + DEPENDENCIES + myrack! + + BUNDLED WITH + #{Bundler::VERSION} + L + end + + it "shows an error" do + bundle "install", raise_on_error: false + + expect(err).to include("Your lockfile contains a single rubygems source section with multiple remotes, which is insecure. Make sure you run `bundle install` in non frozen mode and commit the result to make your lockfile secure.") + end + end + + context "bundle install with a lockfile including X64_MINGW_LEGACY platform" do + before do + gemfile <<~G + source "https://gem.repo1" + gem "rake" + G + + lockfile <<~L + GEM + remote: https://rubygems.org/ + specs: + rake (10.3.2) + + PLATFORMS + ruby + x64-mingw32 + + DEPENDENCIES + rake + + BUNDLED WITH + #{Bundler::VERSION} + L + end + + it "warns a helpful error" do + bundle "install", raise_on_error: false + + expect(err).to include("Found x64-mingw32 in lockfile, which is deprecated and will be removed in the future.") + end + end + + context "with a global path source" do + before do + build_lib "foo" + + install_gemfile <<-G, raise_on_error: false + path "#{lib_path("foo-1.0")}" + gem 'foo' + G + end + + it "shows an error" do + expect(err).to include("You can no longer specify a path source by itself") + end + end + context "when Bundler.setup is run in a ruby script" do - it "should print a single deprecation warning" do - create_file "gems.rb" - install_gemfile! <<-G - source "file://#{gem_repo1}" - gem "rack", :group => :test + before do + create_file "gems.rb", "source 'https://gem.repo1'" + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack", :group => :test G ruby <<-RUBY - require 'rubygems' require 'bundler' - require 'bundler/vendored_thor' - Bundler.ui = Bundler::UI::Shell.new 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.locked." + ) end end context "when `bundler/deployment` is required in a ruby script" do - it "should print a capistrano deprecation warning" do - ruby(<<-RUBY) + before do + ruby <<-RUBY, raise_on_error: false require 'bundler/deployment' RUBY + end - expect(warnings).to have_major_deprecation("Bundler no longer integrates " \ + it "should print a capistrano deprecation warning" do + expect(err).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 end - describe Bundler::Dsl do + context "when `bundler/capistrano` is required in a ruby script" do before do - @rubygems = double("rubygems") - allow(Bundler::Source::Rubygems).to receive(:new) { @rubygems } + ruby <<-RUBY, raise_on_error: false + require 'bundler/capistrano' + RUBY 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 2.0. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work: + it "fails with a helpful error" do + expect(err).to include("[REMOVED] The Bundler task for Capistrano. Please use https://github.com/capistrano/bundler") + end + end - git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" } + context "when `bundler/vlad` is required in a ruby script" do + before do + ruby <<-RUBY, raise_on_error: false + require 'bundler/vlad' + RUBY + end - EOS - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) - subject.gem("sparks", :github => "indirect/sparks") + it "fails with a helpful error" do + expect(err).to include("[REMOVED] The Bundler task for Vlad") + end + end + + context "bundle show" do + before do + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack" + G + end + + context "with --outdated flag" do + before do + bundle "show --outdated", raise_on_error: false 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 2.0. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work: + it "fails with a helpful message" do + expect(err).to include("the `--outdated` flag to `bundle show` has been removed in favor of `bundle show --verbose`") + end + end + end - git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" } + context "bundle remove" do + before do + gemfile <<-G + source "https://gem.repo1" + gem "myrack" + G + end + + context "with --install" do + it "fails with a helpful message" do + bundle "remove myrack --install", raise_on_error: false - EOS - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, "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) + expect(err).to include "The `--install` flag has been removed. `bundle install` is triggered by default." end end + end - context "with bitbucket gems" do - 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 2.0. Add this code to the top of your Gemfile to ensure it continues to work: + context "bundle viz" do + before do + bundle "viz", raise_on_error: false + end - git_source(:bitbucket) do |repo_name| - user_name, repo_name = repo_name.split("/") - repo_name ||= user_name - "https://\#{user_name}@bitbucket.org/\#{user_name}/\#{repo_name}.git" + it "fails with a helpful message" do + expect(err).to include "The `viz` command has been renamed to `graph` and moved to a plugin. See https://github.com/rubygems/bundler-graph" end + end - EOS - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) - subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails") - end + context "bundle inject" do + before do + bundle "inject", raise_on_error: false end - 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 2.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" - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) - subject.gem("not-really-a-gem", :gist => "1234") + it "fails with a helpful message" do + expect(err).to include "The `inject` command has been replaced by the `add` command" + end + end + + context "bundle plugin install --local_git" do + before do + build_git "foo" do |s| + s.write "plugins.rb" end end + + it "fails with a helpful message" do + bundle "plugin install foo --local_git #{lib_path("foo-1.0")}", raise_on_error: false + + expect(err).to include "--local_git has been removed, use --git" + end end - context "bundle show" do - it "prints a deprecation warning" do - install_gemfile! <<-G - source "file://#{gem_repo1}" - gem "rack" - G + describe "removing rubocop" do + before do + bundle_config_global "gem.mit false" + bundle_config_global "gem.test false" + bundle_config_global "gem.coc false" + bundle_config_global "gem.ci false" + bundle_config_global "gem.changelog false" + end + + context "bundle gem --rubocop" do + before do + bundle "gem my_new_gem --rubocop", raise_on_error: false + end - bundle! :show + it "prints an error" do + expect(err).to include \ + "--rubocop has been removed, use --linter=rubocop" + end + end - warnings.gsub!(/gems included.*?\[DEPRECATED/im, "[DEPRECATED") + context "bundle gem --no-rubocop" do + before do + bundle "gem my_new_gem --no-rubocop", raise_on_error: false + end - expect(warnings).to have_major_deprecation a_string_including("use `bundle list` instead of `bundle show`") + it "prints an error" do + expect(err).to include \ + "--no-rubocop has been removed, use --no-linter" + end end end - context "bundle console" do - it "prints a deprecation warning" do - bundle "console" + context " bundle gem --ext parameter with no value" do + it "prints error when used before gem name" do + bundle "gem --ext foo", raise_on_error: false + expect(err).to include "Extensions can now be generated using C or Rust, so `--ext` with no arguments has been removed. Please select a language, e.g. `--ext=rust` to generate a Rust extension." + 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 error when used after gem name" do + bundle "gem foo --ext", raise_on_error: false + expect(err).to include "Extensions can now be generated using C or Rust, so `--ext` with no arguments has been removed. Please select a language, e.g. `--ext=rust` to generate a Rust extension." end end end diff --git a/spec/bundler/other/platform_spec.rb b/spec/bundler/other/platform_spec.rb deleted file mode 100644 index fea5daf5ac..0000000000 --- a/spec/bundler/other/platform_spec.rb +++ /dev/null @@ -1,1299 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe "bundle platform" do - context "without flags" do - let(:bundle_platform_platforms_string) do - platforms = [rb] - platforms.unshift(specific_local_platform) if Bundler.feature_flag.bundler_2_mode? - platforms.map {|pl| "* #{pl}" }.join("\n") - end - - it "returns all the output" do - gemfile <<-G - source "file://#{gem_repo1}" - - #{ruby_version_correct} - - gem "foo" - G - - bundle "platform" - expect(out).to eq(<<-G.chomp) -Your platform is: #{RUBY_PLATFORM} - -Your app has gems that work on these platforms: -#{bundle_platform_platforms_string} - -Your Gemfile specifies a Ruby version requirement: -* ruby #{RUBY_VERSION} - -Your current platform satisfies the Ruby version requirement. -G - end - - it "returns all the output including the patchlevel" do - gemfile <<-G - source "file://#{gem_repo1}" - - #{ruby_version_correct_patchlevel} - - gem "foo" - G - - bundle "platform" - expect(out).to eq(<<-G.chomp) -Your platform is: #{RUBY_PLATFORM} - -Your app has gems that work on these platforms: -#{bundle_platform_platforms_string} - -Your Gemfile specifies a Ruby version requirement: -* ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL} - -Your current platform satisfies the Ruby version requirement. -G - end - - it "doesn't print ruby version requirement if it isn't specified" do - gemfile <<-G - source "file://#{gem_repo1}" - - gem "foo" - G - - bundle "platform" - expect(out).to eq(<<-G.chomp) -Your platform is: #{RUBY_PLATFORM} - -Your app has gems that work on these platforms: -#{bundle_platform_platforms_string} - -Your Gemfile does not specify a Ruby version requirement. -G - end - - it "doesn't match the ruby version requirement" do - gemfile <<-G - source "file://#{gem_repo1}" - - #{ruby_version_incorrect} - - gem "foo" - G - - bundle "platform" - expect(out).to eq(<<-G.chomp) -Your platform is: #{RUBY_PLATFORM} - -Your app has gems that work on these platforms: -#{bundle_platform_platforms_string} - -Your Gemfile specifies a Ruby version requirement: -* ruby #{not_local_ruby_version} - -Your Ruby version is #{RUBY_VERSION}, but your Gemfile specified #{not_local_ruby_version} -G - end - end - - context "--ruby" do - it "returns ruby version when explicit" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.9.3", :engine => 'ruby', :engine_version => '1.9.3' - - gem "foo" - G - - bundle "platform --ruby" - - expect(out).to eq("ruby 1.9.3") - end - - it "defaults to MRI" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.9.3" - - gem "foo" - G - - bundle "platform --ruby" - - expect(out).to eq("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 "platform --ruby" - - expect(out).to eq("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 "platform --ruby" - - expect(out).to eq("ruby 1.8.7 (rbx 1.2.4)") - 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 "platform" - - expect(exitstatus).not_to eq(0) if exitstatus - 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 "platform" - - expect(exitstatus).not_to eq(0) if exitstatus - 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 "platform" - - expect(exitstatus).not_to eq(0) if exitstatus - end - - it "should print if no ruby version is specified" do - gemfile <<-G - source "file://#{gem_repo1}" - - gem "foo" - G - - bundle "platform --ruby" - - expect(out).to eq("No ruby version specified") - end - - it "handles when there is a locked requirement" do - gemfile <<-G - ruby "< 1.8.7" - G - - lockfile <<-L - GEM - specs: - - PLATFORMS - ruby - - DEPENDENCIES - - RUBY VERSION - ruby 1.0.0p127 - - BUNDLED WITH - #{Bundler::VERSION} - L - - bundle! "platform --ruby" - expect(out).to eq("ruby 1.0.0p127") - end - - it "handles when there is a requirement in the gemfile" do - gemfile <<-G - ruby ">= 1.8.7" - G - - bundle! "platform --ruby" - expect(out).to eq("ruby 1.8.7") - end - - it "handles when there are multiple requirements in the gemfile" do - gemfile <<-G - ruby ">= 1.8.7", "< 2.0.0" - G - - bundle! "platform --ruby" - expect(out).to eq("ruby 1.8.7") - end - end - - let(:ruby_version_correct) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{local_engine_version}\"" } - let(:ruby_version_correct_engineless) { "ruby \"#{RUBY_VERSION}\"" } - let(:ruby_version_correct_patchlevel) { "#{ruby_version_correct}, :patchlevel => '#{RUBY_PATCHLEVEL}'" } - let(:ruby_version_incorrect) { "ruby \"#{not_local_ruby_version}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{not_local_ruby_version}\"" } - let(:engine_incorrect) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{not_local_tag}\", :engine_version => \"#{RUBY_VERSION}\"" } - let(:engine_version_incorrect) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{not_local_engine_version}\"" } - let(:patchlevel_incorrect) { "#{ruby_version_correct}, :patchlevel => '#{not_local_patchlevel}'" } - let(:patchlevel_fixnum) { "#{ruby_version_correct}, :patchlevel => #{RUBY_PATCHLEVEL}1" } - - 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}") - 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}") - 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}") - 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}") - 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") - end - - context "bundle install" do - it "installs fine when the ruby version matches" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{ruby_version_correct} - G - - expect(bundled_app("Gemfile.lock")).to exist - end - - it "installs fine with any engine" do - simulate_ruby_engine "jruby" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{ruby_version_correct_engineless} - G - - expect(bundled_app("Gemfile.lock")).to exist - end - end - - it "installs fine when the patchlevel matches" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{ruby_version_correct_patchlevel} - G - - expect(bundled_app("Gemfile.lock")).to exist - end - - it "doesn't install when the ruby version doesn't match" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{ruby_version_incorrect} - G - - expect(bundled_app("Gemfile.lock")).not_to exist - should_be_ruby_version_incorrect - end - - it "doesn't install when engine doesn't match" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{engine_incorrect} - G - - expect(bundled_app("Gemfile.lock")).not_to exist - should_be_engine_incorrect - end - - it "doesn't install when engine version doesn't match" do - simulate_ruby_engine "jruby" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{engine_version_incorrect} - G - - expect(bundled_app("Gemfile.lock")).not_to exist - should_be_engine_version_incorrect - end - end - - it "doesn't install when patchlevel doesn't match" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{patchlevel_incorrect} - G - - expect(bundled_app("Gemfile.lock")).not_to exist - should_be_patchlevel_incorrect - end - end - - context "bundle check" do - it "checks fine when the ruby version matches" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - G - - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{ruby_version_correct} - G - - bundle :check - expect(exitstatus).to eq(0) if exitstatus - expect(out).to eq("Resolving dependencies...\nThe Gemfile's dependencies are satisfied") - end - - it "checks fine with any engine" do - simulate_ruby_engine "jruby" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - G - - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{ruby_version_correct_engineless} - G - - bundle :check - expect(exitstatus).to eq(0) if exitstatus - expect(out).to eq("Resolving dependencies...\nThe Gemfile's dependencies are satisfied") - end - end - - it "fails when ruby version doesn't match" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - G - - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{ruby_version_incorrect} - G - - bundle :check - should_be_ruby_version_incorrect - end - - it "fails when engine doesn't match" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - G - - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{engine_incorrect} - G - - bundle :check - should_be_engine_incorrect - end - - it "fails when engine version doesn't match" do - simulate_ruby_engine "ruby" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - G - - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{engine_version_incorrect} - G - - bundle :check - should_be_engine_version_incorrect - end - end - - it "fails when patchlevel doesn't match" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - G - - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{patchlevel_incorrect} - G - - bundle :check - should_be_patchlevel_incorrect - end - end - - context "bundle update" do - before do - build_repo2 - - install_gemfile <<-G - source "file://#{gem_repo2}" - gem "activesupport" - gem "rack-obama" - G - end - - it "updates successfully when the ruby version matches" do - gemfile <<-G - source "file://#{gem_repo2}" - gem "activesupport" - gem "rack-obama" - - #{ruby_version_correct} - G - update_repo2 do - build_gem "activesupport", "3.0" - end - - bundle "update", :all => bundle_update_requires_all? - expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0" - end - - it "updates fine with any engine" do - simulate_ruby_engine "jruby" do - gemfile <<-G - source "file://#{gem_repo2}" - gem "activesupport" - gem "rack-obama" - - #{ruby_version_correct_engineless} - G - update_repo2 do - build_gem "activesupport", "3.0" - end - - bundle "update", :all => bundle_update_requires_all? - expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0" - end - end - - it "fails when ruby version doesn't match" do - gemfile <<-G - source "file://#{gem_repo2}" - gem "activesupport" - gem "rack-obama" - - #{ruby_version_incorrect} - G - update_repo2 do - build_gem "activesupport", "3.0" - end - - bundle :update, :all => bundle_update_requires_all? - should_be_ruby_version_incorrect - end - - it "fails when ruby engine doesn't match" do - gemfile <<-G - source "file://#{gem_repo2}" - gem "activesupport" - gem "rack-obama" - - #{engine_incorrect} - G - update_repo2 do - build_gem "activesupport", "3.0" - end - - bundle :update, :all => bundle_update_requires_all? - should_be_engine_incorrect - end - - it "fails when ruby engine version doesn't match" do - simulate_ruby_engine "jruby" do - gemfile <<-G - source "file://#{gem_repo2}" - gem "activesupport" - gem "rack-obama" - - #{engine_version_incorrect} - G - update_repo2 do - build_gem "activesupport", "3.0" - end - - bundle :update, :all => bundle_update_requires_all? - should_be_engine_version_incorrect - end - end - - it "fails when patchlevel doesn't match" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{patchlevel_incorrect} - G - update_repo2 do - build_gem "activesupport", "3.0" - end - - bundle :update, :all => bundle_update_requires_all? - should_be_patchlevel_incorrect - end - end - - context "bundle info" do - before do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rails" - G - end - - it "prints path if ruby version is correct" do - install_gemfile! <<-G - source "file://#{gem_repo1}" - gem "rails" - - #{ruby_version_correct} - G - - bundle "info rails --path" - expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s) - end - - it "prints path if ruby version is correct for any engine" do - simulate_ruby_engine "jruby" do - install_gemfile! <<-G - source "file://#{gem_repo1}" - gem "rails" - - #{ruby_version_correct_engineless} - G - - bundle "info rails --path" - expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s) - end - end - - it "fails if ruby version doesn't match", :bundler => "< 2" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rails" - - #{ruby_version_incorrect} - G - - bundle "show rails" - should_be_ruby_version_incorrect - end - - it "fails if engine doesn't match", :bundler => "< 2" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rails" - - #{engine_incorrect} - G - - bundle "show rails" - should_be_engine_incorrect - end - - it "fails if engine version doesn't match", :bundler => "< 2" do - simulate_ruby_engine "jruby" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rails" - - #{engine_version_incorrect} - G - - bundle "show rails" - should_be_engine_version_incorrect - end - end - - it "fails when patchlevel doesn't match", :bundler => "< 2" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{patchlevel_incorrect} - G - update_repo2 do - build_gem "activesupport", "3.0" - end - - bundle "show rails" - should_be_patchlevel_incorrect - end - end - - context "bundle cache" do - before do - install_gemfile <<-G - source "file:#{gem_repo1}" - gem 'rack' - G - end - - it "copies the .gem file to vendor/cache when ruby version matches" do - gemfile <<-G - gem 'rack' - - #{ruby_version_correct} - G - - bundle :cache - expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist - end - - it "copies the .gem file to vendor/cache when ruby version matches for any engine" do - simulate_ruby_engine "jruby" do - install_gemfile! <<-G - source "file:#{gem_repo1}" - gem 'rack' - - #{ruby_version_correct_engineless} - G - - bundle! :cache - expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist - end - end - - it "fails if the ruby version doesn't match" do - gemfile <<-G - gem 'rack' - - #{ruby_version_incorrect} - G - - bundle :cache - should_be_ruby_version_incorrect - end - - it "fails if the engine doesn't match" do - gemfile <<-G - gem 'rack' - - #{engine_incorrect} - G - - bundle :cache - should_be_engine_incorrect - end - - it "fails if the engine version doesn't match" do - simulate_ruby_engine "jruby" do - gemfile <<-G - gem 'rack' - - #{engine_version_incorrect} - G - - bundle :cache - should_be_engine_version_incorrect - end - end - - it "fails when patchlevel doesn't match" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{patchlevel_incorrect} - G - - bundle :cache - should_be_patchlevel_incorrect - end - end - - context "bundle pack" do - before do - install_gemfile! <<-G - source "file:#{gem_repo1}" - gem 'rack' - G - end - - it "copies the .gem file to vendor/cache when ruby version matches" do - gemfile <<-G - gem 'rack' - - #{ruby_version_correct} - G - - bundle :pack - expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist - end - - it "copies the .gem file to vendor/cache when ruby version matches any engine" do - simulate_ruby_engine "jruby" do - install_gemfile! <<-G - source "file:#{gem_repo1}" - gem 'rack' - - #{ruby_version_correct_engineless} - G - - bundle :pack - expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist - end - end - - it "fails if the ruby version doesn't match" do - gemfile <<-G - gem 'rack' - - #{ruby_version_incorrect} - G - - bundle :pack - should_be_ruby_version_incorrect - end - - it "fails if the engine doesn't match" do - gemfile <<-G - gem 'rack' - - #{engine_incorrect} - G - - bundle :pack - should_be_engine_incorrect - end - - it "fails if the engine version doesn't match" do - simulate_ruby_engine "jruby" do - gemfile <<-G - gem 'rack' - - #{engine_version_incorrect} - G - - bundle :pack - should_be_engine_version_incorrect - end - end - - it "fails when patchlevel doesn't match" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{patchlevel_incorrect} - G - - bundle :pack - should_be_patchlevel_incorrect - end - end - - context "bundle exec" do - before do - ENV["BUNDLER_FORCE_TTY"] = "true" - system_gems "rack-1.0.0", "rack-0.9.1", :path => :bundle_path - end - - it "activates the correct gem when ruby version matches" do - gemfile <<-G - gem "rack", "0.9.1" - - #{ruby_version_correct} - G - - bundle "exec rackup" - expect(out).to eq("0.9.1") - end - - it "activates the correct gem when ruby version matches any engine" do - simulate_ruby_engine "jruby" do - system_gems "rack-1.0.0", "rack-0.9.1", :path => :bundle_path - gemfile <<-G - gem "rack", "0.9.1" - - #{ruby_version_correct_engineless} - G - - bundle "exec rackup" - expect(out).to eq("0.9.1") - end - end - - it "fails when the ruby version doesn't match" do - gemfile <<-G - gem "rack", "0.9.1" - - #{ruby_version_incorrect} - G - - bundle "exec rackup" - should_be_ruby_version_incorrect - end - - it "fails when the engine doesn't match" do - gemfile <<-G - gem "rack", "0.9.1" - - #{engine_incorrect} - G - - bundle "exec rackup" - should_be_engine_incorrect - end - - # it "fails when the engine version doesn't match" do - # simulate_ruby_engine "jruby" do - # gemfile <<-G - # gem "rack", "0.9.1" - # - # #{engine_version_incorrect} - # G - # - # bundle "exec rackup" - # should_be_engine_version_incorrect - # end - # end - - it "fails when patchlevel doesn't match" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - #{patchlevel_incorrect} - G - - bundle "exec rackup" - should_be_patchlevel_incorrect - end - end - - context "bundle console", :bundler => "< 2" do - before do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - gem "activesupport", :group => :test - gem "rack_middleware", :group => :development - G - end - - it "starts IRB with the default group loaded when ruby version matches" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - gem "activesupport", :group => :test - gem "rack_middleware", :group => :development - - #{ruby_version_correct} - G - - bundle "console" do |input, _, _| - input.puts("puts RACK") - input.puts("exit") - end - expect(out).to include("0.9.1") - end - - it "starts IRB with the default group loaded when ruby version matches any engine" do - simulate_ruby_engine "jruby" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - gem "activesupport", :group => :test - gem "rack_middleware", :group => :development - - #{ruby_version_correct_engineless} - G - - bundle "console" do |input, _, _| - input.puts("puts RACK") - input.puts("exit") - end - expect(out).to include("0.9.1") - end - end - - it "fails when ruby version doesn't match" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - gem "activesupport", :group => :test - gem "rack_middleware", :group => :development - - #{ruby_version_incorrect} - G - - bundle "console" - should_be_ruby_version_incorrect - end - - it "fails when engine doesn't match" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - gem "activesupport", :group => :test - gem "rack_middleware", :group => :development - - #{engine_incorrect} - G - - bundle "console" - should_be_engine_incorrect - end - - it "fails when engine version doesn't match" do - simulate_ruby_engine "jruby" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - gem "activesupport", :group => :test - gem "rack_middleware", :group => :development - - #{engine_version_incorrect} - G - - bundle "console" - should_be_engine_version_incorrect - end - end - - it "fails when patchlevel doesn't match" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - gem "activesupport", :group => :test - gem "rack_middleware", :group => :development - - #{patchlevel_incorrect} - G - - bundle "console" - should_be_patchlevel_incorrect - end - end - - context "Bundler.setup" do - before do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "yard" - gem "rack", :group => :test - G - - ENV["BUNDLER_FORCE_TTY"] = "true" - end - - it "makes a Gemfile.lock if setup succeeds" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "yard" - gem "rack" - - #{ruby_version_correct} - G - - FileUtils.rm(bundled_app("Gemfile.lock")) - - run "1" - expect(bundled_app("Gemfile.lock")).to exist - end - - it "makes a Gemfile.lock if setup succeeds for any engine" do - simulate_ruby_engine "jruby" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "yard" - gem "rack" - - #{ruby_version_correct_engineless} - G - - FileUtils.rm(bundled_app("Gemfile.lock")) - - run "1" - expect(bundled_app("Gemfile.lock")).to exist - end - end - - it "fails when ruby version doesn't match" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "yard" - gem "rack" - - #{ruby_version_incorrect} - G - - FileUtils.rm(bundled_app("Gemfile.lock")) - - ruby <<-R - require 'rubygems' - require 'bundler/setup' - R - - expect(bundled_app("Gemfile.lock")).not_to exist - should_be_ruby_version_incorrect - end - - it "fails when engine doesn't match" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "yard" - gem "rack" - - #{engine_incorrect} - G - - FileUtils.rm(bundled_app("Gemfile.lock")) - - ruby <<-R - require 'rubygems' - require 'bundler/setup' - R - - expect(bundled_app("Gemfile.lock")).not_to exist - should_be_engine_incorrect - end - - it "fails when engine version doesn't match" do - simulate_ruby_engine "jruby" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "yard" - gem "rack" - - #{engine_version_incorrect} - G - - FileUtils.rm(bundled_app("Gemfile.lock")) - - ruby <<-R - require 'rubygems' - require 'bundler/setup' - R - - expect(bundled_app("Gemfile.lock")).not_to exist - should_be_engine_version_incorrect - end - end - - it "fails when patchlevel doesn't match" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "yard" - gem "rack" - - #{patchlevel_incorrect} - G - - FileUtils.rm(bundled_app("Gemfile.lock")) - - ruby <<-R - require 'rubygems' - require 'bundler/setup' - R - - expect(bundled_app("Gemfile.lock")).not_to exist - should_be_patchlevel_incorrect - end - end - - context "bundle outdated" do - before do - build_repo2 do - build_git "foo", :path => lib_path("foo") - end - - install_gemfile <<-G - source "file://#{gem_repo2}" - gem "activesupport", "2.3.5" - gem "foo", :git => "#{lib_path("foo")}" - G - end - - it "returns list of outdated gems when the ruby version matches" do - update_repo2 do - build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") - end - - gemfile <<-G - source "file://#{gem_repo2}" - gem "activesupport", "2.3.5" - gem "foo", :git => "#{lib_path("foo")}" - - #{ruby_version_correct} - G - - bundle "outdated" - expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5") - expect(out).to include("foo (newest 1.0") - end - - it "returns list of outdated gems when the ruby version matches for any engine" do - simulate_ruby_engine "jruby" do - bundle! :install - update_repo2 do - build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") - end - - gemfile <<-G - source "file://#{gem_repo2}" - gem "activesupport", "2.3.5" - gem "foo", :git => "#{lib_path("foo")}" - - #{ruby_version_correct_engineless} - G - - bundle "outdated" - expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5)") - expect(out).to include("foo (newest 1.0") - end - end - - it "fails when the ruby version doesn't match" do - update_repo2 do - build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") - end - - gemfile <<-G - source "file://#{gem_repo2}" - gem "activesupport", "2.3.5" - gem "foo", :git => "#{lib_path("foo")}" - - #{ruby_version_incorrect} - G - - bundle "outdated" - should_be_ruby_version_incorrect - end - - it "fails when the engine doesn't match" do - update_repo2 do - build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") - end - - gemfile <<-G - source "file://#{gem_repo2}" - gem "activesupport", "2.3.5" - gem "foo", :git => "#{lib_path("foo")}" - - #{engine_incorrect} - G - - bundle "outdated" - should_be_engine_incorrect - end - - it "fails when the engine version doesn't match" do - simulate_ruby_engine "jruby" do - update_repo2 do - build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") - end - - gemfile <<-G - source "file://#{gem_repo2}" - gem "activesupport", "2.3.5" - gem "foo", :git => "#{lib_path("foo")}" - - #{engine_version_incorrect} - G - - bundle "outdated" - should_be_engine_version_incorrect - end - end - - it "fails when the patchlevel doesn't match" do - simulate_ruby_engine "jruby" do - update_repo2 do - build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") - end - - gemfile <<-G - source "file://#{gem_repo2}" - gem "activesupport", "2.3.5" - gem "foo", :git => "#{lib_path("foo")}" - - #{patchlevel_incorrect} - G - - bundle "outdated" - should_be_patchlevel_incorrect - end - end - - it "fails when the patchlevel is a fixnum" do - simulate_ruby_engine "jruby" do - update_repo2 do - build_gem "activesupport", "3.0" - update_git "foo", :path => lib_path("foo") - end - - gemfile <<-G - source "file://#{gem_repo2}" - gem "activesupport", "2.3.5" - gem "foo", :git => "#{lib_path("foo")}" - - #{patchlevel_fixnum} - G - - bundle "outdated" - should_be_patchlevel_fixnum - end - end - 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 |
