diff --git a/.rubocop.yml b/.rubocop.yml index a6412ecb135..cbdb8f8d41c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,7 +2,7 @@ inherit_from: - .rubocop_todo.yml AllCops: - TargetRubyVersion: 1.9 + TargetRubyVersion: 2.3 Exclude: - tmp/**/* - lib/bundler/vendor/**/* diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e8c49c05c40..70e346e65f8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2017-09-17 16:46:43 +0900 using RuboCop version 0.50.0. +# on 2019-01-04 16:12:29 +1100 using RuboCop version 0.50.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -13,7 +13,7 @@ Layout/IndentArray: EnforcedStyle: consistent -# Offense count: 40 +# Offense count: 46 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent @@ -29,7 +29,7 @@ Layout/MultilineMethodCallIndentation: - 'lib/bundler/cli/common.rb' - 'spec/bundler/plugin/source_list_spec.rb' -# Offense count: 31 +# Offense count: 30 Lint/AmbiguousBlockAssociation: Exclude: - 'lib/bundler/definition.rb' @@ -51,7 +51,7 @@ Lint/EmptyWhen: - 'lib/bundler/friendly_errors.rb' - 'spec/support/builders.rb' -# Offense count: 3 +# Offense count: 4 Lint/HandleExceptions: Exclude: - 'lib/bundler/psyched_yaml.rb' @@ -86,9 +86,17 @@ Lint/RescueException: - 'lib/bundler/rubygems_integration.rb' - 'lib/bundler/worker.rb' -# Offense count: 29 +# Offense count: 13 Lint/RescueWithoutErrorClass: - Enabled: false + Exclude: + - 'Rakefile' + - 'lib/bundler/friendly_errors.rb' + - 'lib/bundler/resolver.rb' + - 'lib/bundler/retry.rb' + - 'lib/bundler/source/rubygems.rb' + - 'spec/support/artifice/compact_index.rb' + - 'spec/support/helpers.rb' + - 'spec/support/matchers.rb' # Offense count: 2 Lint/ShadowedException: @@ -102,13 +110,12 @@ Lint/UselessAccessModifier: Exclude: - 'lib/bundler/fetcher.rb' -# Offense count: 6 +# Offense count: 1 Lint/UselessAssignment: Exclude: - 'lib/bundler/index.rb' - - 'lib/bundler/installer.rb' -# Offense count: 2564 +# Offense count: 2856 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: @@ -119,7 +126,7 @@ Naming/AccessorMethodName: Exclude: - 'lib/bundler/source/git.rb' -# Offense count: 31 +# Offense count: 33 # Configuration parameters: Blacklist. # Blacklist: END, (?-mix:EO[A-Z]{1}) Naming/HeredocDelimiterNaming: @@ -160,7 +167,7 @@ Performance/HashEachMethods: - 'spec/support/builders.rb' - 'spec/support/helpers.rb' -# Offense count: 7 +# Offense count: 8 # Cop supports --auto-correct. Performance/RedundantBlockCall: Exclude: @@ -183,6 +190,10 @@ Performance/RedundantMerge: Exclude: - 'lib/bundler/cli/gem.rb' +# Offense count: 35 +Performance/UnfreezeString: + Enabled: false + # Offense count: 4 Security/Eval: Exclude: @@ -204,7 +215,7 @@ Style/CaseEquality: - 'lib/bundler/match_platform.rb' - 'lib/bundler/rubygems_ext.rb' -# Offense count: 27 +# Offense count: 28 # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: nested, compact Style/ClassAndModuleChildren: @@ -226,7 +237,7 @@ Style/ConditionalAssignment: - 'lib/bundler/source/git.rb' - 'lib/bundler/source/rubygems.rb' -# Offense count: 167 +# Offense count: 169 Style/Documentation: Enabled: false @@ -243,7 +254,7 @@ Style/EmptyMethod: - 'lib/bundler/ui/silent.rb' - 'spec/support/artifice/fail.rb' -# Offense count: 5 +# Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, AutoCorrectEncodingComment. # SupportedStyles: when_needed, always, never @@ -270,7 +281,7 @@ Style/GlobalVars: - 'lib/bundler/cli.rb' - 'spec/spec_helper.rb' -# Offense count: 12 +# Offense count: 11 # Configuration parameters: MinBodyLength. Style/GuardClause: Exclude: @@ -283,7 +294,6 @@ Style/GuardClause: - 'lib/bundler/runtime.rb' - 'lib/bundler/source/path/installer.rb' - 'lib/bundler/source_list.rb' - - 'spec/commands/newgem_spec.rb' - 'spec/support/sometimes.rb' # Offense count: 9 @@ -327,14 +337,14 @@ Style/MultilineIfModifier: - 'lib/bundler/runtime.rb' - 'lib/bundler/source/rubygems.rb' -# Offense count: 5 +# Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: - 'spec/**/*' - - 'lib/bundler/gem_helper.rb' + - 'lib/bundler/cli/common.rb' - 'lib/bundler/mirror.rb' - 'lib/bundler/source/path.rb' @@ -360,6 +370,38 @@ Style/RaiseArgs: - 'spec/bundler/rubygems_integration_spec.rb' - 'spec/bundler/shared_helpers_spec.rb' +# Offense count: 24 +# Cop supports --auto-correct. +Style/RedundantFreeze: + Exclude: + - 'bin/bundle1' + - 'bin/bundle2' + - 'lib/bundler.rb' + - 'lib/bundler/endpoint_specification.rb' + - 'lib/bundler/environment_preserver.rb' + - 'lib/bundler/index.rb' + - 'lib/bundler/injector.rb' + - 'lib/bundler/installer.rb' + - 'lib/bundler/lockfile_generator.rb' + - 'lib/bundler/lockfile_parser.rb' + - 'lib/bundler/plugin.rb' + - 'lib/bundler/resolver/spec_group.rb' + - 'lib/bundler/source/path.rb' + - 'spec/bundler/shared_helpers_spec.rb' + +# Offense count: 40 +# Cop supports --auto-correct. +# Configuration parameters: ConvertCodeThatCanStartToReturnNil. +Style/SafeNavigation: + Enabled: false + +# Offense count: 57 +# Cop supports --auto-correct. +# Configuration parameters: MinSize, SupportedStyles. +# SupportedStyles: percent, brackets +Style/SymbolArray: + EnforcedStyle: brackets + # Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline. diff --git a/.travis.yml b/.travis.yml index 02c60d693c8..e40d1930fec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -74,13 +74,6 @@ jobs: - rvm: ruby-head env: RGV=master stage: test - # 1.x mode (we want to keep stuff passing in 1.x mode for now) - - rvm: 2.6.0 - env: RGV=v2.7.7 BUNDLER_SPEC_SUB_VERSION=1.98 - stage: test - - rvm: 1.8.7 - env: RGV=v2.7.7 BUNDLER_SPEC_SUB_VERSION=1.98 - stage: test allow_failures: - rvm: ruby-head diff --git a/CHANGELOG.md b/CHANGELOG.md index d86054b2ff3..1e5a2452ad0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ +## 2.0.1 (2019-01-04) + +Changes: + + - Relaxed RubyGems requirement to `>= 2.5.0` ([#6867](https://github.com/bundler/bundler/pull/6867)) + +## 2.0.0 (2019-01-03) + +No new changes + +## 2.0.0.pre.3 (2018-12-30) + +Breaking Changes: + + - Bundler 2 now requires RubyGems 3.0.0 at minimum + +Changes: + + - Ruby 2.6 compatibility fixes (@segiddins) + - Import changes from Bundler 1.17.3 release + +Note: To upgrade your Gemfile to Bundler 2 you will need to run `bundle update --bundler` + ## 1.17.3 (2018-12-27) Bugfixes: @@ -13,6 +36,28 @@ Documentation: - Add compatibility for bundler merge with Ruby 2.6 +## 2.0.0.pre.2 (2018-11-27) + +Breaking Changes: + + - `:github` source in the Gemfile now defaults to using HTTPS + +Changes + + - Add compatibility for Bundler merge into ruby-src + +Note: To upgrade your Gemfile to Bundler 2 you will need to run `bundle update --bundler` + +## 2.0.0.pre.1 (2018-11-09) + +Breaking Changes: + + - Dropped support for versions of Ruby < 2.3 + - Dropped support for version of RubyGems < 2.5 + - Moved error messages from STDOUT to STDERR + +Note: To upgrade your Gemfile to Bundler 2 you will need to run `bundle update --bundler` + ## 1.17.1 (2018-10-25) - Convert `Pathname`s to `String`s before sorting them, fixing #6760 and #6758 ([#6761](https://github.com/bundler/bundler/pull/6761), @alexggordon) diff --git a/exe/bundle_ruby b/exe/bundle_ruby index df6f8cc8a1d..2209c6195f8 100755 --- a/exe/bundle_ruby +++ b/exe/bundle_ruby @@ -3,7 +3,7 @@ require "bundler/shared_helpers" -Bundler::SharedHelpers.major_deprecation(2, "the bundle_ruby executable has been removed in favor of `bundle platform --ruby`") +Bundler::SharedHelpers.major_deprecation(3, "the bundle_ruby executable has been removed in favor of `bundle platform --ruby`") Signal.trap("INT") { exit 1 } diff --git a/lib/bundler.rb b/lib/bundler.rb index 137d916cc66..357d971a523 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -119,7 +119,7 @@ def load end def environment - SharedHelpers.major_deprecation 2, "Bundler.environment has been removed in favor of Bundler.load" + SharedHelpers.major_deprecation 3, "Bundler.environment has been removed in favor of Bundler.load" load end @@ -283,7 +283,7 @@ def original_env # @deprecated Use `unbundled_env` instead def clean_env Bundler::SharedHelpers.major_deprecation( - 2, + 3, "`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`" ) @@ -322,7 +322,7 @@ def with_original_env # @deprecated Use `with_unbundled_env` instead def with_clean_env Bundler::SharedHelpers.major_deprecation( - 2, + 3, "`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`" ) diff --git a/lib/bundler/capistrano.rb b/lib/bundler/capistrano.rb index 1b7145b72be..40e2e5dbe8b 100644 --- a/lib/bundler/capistrano.rb +++ b/lib/bundler/capistrano.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "bundler/shared_helpers" -Bundler::SharedHelpers.major_deprecation 2, +Bundler::SharedHelpers.major_deprecation 3, "The Bundler task for Capistrano. Please use http://github.com/capistrano/bundler" # Capistrano task for Bundler. diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index c591884263e..7ca1a78a1a7 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -229,7 +229,7 @@ def remove(*gems) "Include gems that are part of the specified named group." map "i" => "install" def install - SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force") + SharedHelpers.major_deprecation(3, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force") require "bundler/cli/install" Bundler.settings.temporary(:no_install => false) do Install.new(options.dup).run @@ -275,7 +275,7 @@ def install method_option "all", :type => :boolean, :banner => "Update everything." def update(*gems) - SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force") + SharedHelpers.major_deprecation(3, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force") require "bundler/cli/update" Update.new(options, gems).run end @@ -303,7 +303,7 @@ def show(gem_name = nil) old_argv = ARGV.join(" ") new_argv = [new_command, *new_arguments.compact].join(" ") - Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`") + Bundler::SharedHelpers.major_deprecation(3, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`") end require "bundler/cli/show" Show.new(options, gem_name).run @@ -522,23 +522,21 @@ def licenses end end - if Bundler.feature_flag.viz_command? - desc "viz [OPTIONS]", "Generates a visual dependency graph", :hide => true - long_desc <<-D - Viz generates a PNG file of the current Gemfile as a dependency graph. - Viz requires the ruby-graphviz gem (and its dependencies). - The associated gems must also be installed via 'bundle install'. - D - method_option :file, :type => :string, :default => "gem_graph", :aliases => "-f", :desc => "The name to use for the generated file. see format option" - method_option :format, :type => :string, :default => "png", :aliases => "-F", :desc => "This is output format option. Supported format is png, jpg, svg, dot ..." - method_option :requirements, :type => :boolean, :default => false, :aliases => "-R", :desc => "Set to show the version of each required dependency." - method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version." - method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group." - def viz - SharedHelpers.major_deprecation 2, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz" - require "bundler/cli/viz" - Viz.new(options.dup).run - end + desc "viz [OPTIONS]", "Generates a visual dependency graph", :hide => true + long_desc <<-D + Viz generates a PNG file of the current Gemfile as a dependency graph. + Viz requires the ruby-graphviz gem (and its dependencies). + The associated gems must also be installed via 'bundle install'. + D + method_option :file, :type => :string, :default => "gem_graph", :aliases => "-f", :desc => "The name to use for the generated file. see format option" + method_option :format, :type => :string, :default => "png", :aliases => "-F", :desc => "This is output format option. Supported format is png, jpg, svg, dot ..." + method_option :requirements, :type => :boolean, :default => false, :aliases => "-R", :desc => "Set to show the version of each required dependency." + method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version." + method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group." + def viz + SharedHelpers.major_deprecation 3, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz" + require "bundler/cli/viz" + Viz.new(options.dup).run end old_gem = instance_method(:gem) @@ -606,7 +604,7 @@ def platform method_option "group", :type => :string, :banner => "Install gem into a bundler group" def inject(name, version) - SharedHelpers.major_deprecation 2, "The `inject` command has been replaced by the `add` command" + SharedHelpers.major_deprecation 3, "The `inject` command has been replaced by the `add` command" require "bundler/cli/inject" Inject.new(options.dup, name, version).run end diff --git a/lib/bundler/cli/console.rb b/lib/bundler/cli/console.rb index 6e0dfe28afa..c87f22e2ad5 100644 --- a/lib/bundler/cli/console.rb +++ b/lib/bundler/cli/console.rb @@ -9,7 +9,7 @@ def initialize(options, group) end def run - Bundler::SharedHelpers.major_deprecation 2, "bundle console will be replaced " \ + Bundler::SharedHelpers.major_deprecation 3, "bundle console will be replaced " \ "by `bin/console` generated by `bundle gem `" group ? Bundler.require(:default, *group.split.map!(&:to_sym)) : Bundler.require diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index 03edc7fbd24..2e6a7774096 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -53,7 +53,7 @@ def run Bundler::Fetcher.disable_endpoint = options["full-index"] if options["binstubs"] - Bundler::SharedHelpers.major_deprecation 2, + Bundler::SharedHelpers.major_deprecation 3, "The --binstubs option will be removed in favor of `bundle binstubs`" end diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb index b088853768f..bf300a84371 100644 --- a/lib/bundler/cli/update.rb +++ b/lib/bundler/cli/update.rb @@ -22,7 +22,7 @@ def run if Bundler.feature_flag.update_requires_all_flag? raise InvalidOption, "To update everything, pass the `--all` flag." end - SharedHelpers.major_deprecation 2, "Pass --all to `bundle update` to update everything" + SharedHelpers.major_deprecation 3, "Pass --all to `bundle update` to update everything" elsif !full_update && options[:all] raise InvalidOption, "Cannot specify --all along with specific options." end diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 9d6fbfff59c..62eb76b55fc 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -331,7 +331,7 @@ def lock(file, preserve_unknown_sections = false) # i.e., Windows with `git config core.autocrlf=true` contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n") - if @locked_bundler_version + if @locked_bundler_version && Bundler.feature_flag.lockfile_upgrade_warning? locked_major = @locked_bundler_version.segments.first current_major = Gem::Version.create(Bundler::VERSION).segments.first diff --git a/lib/bundler/deployment.rb b/lib/bundler/deployment.rb index 291e158ca01..4c8f48d4056 100644 --- a/lib/bundler/deployment.rb +++ b/lib/bundler/deployment.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "bundler/shared_helpers" -Bundler::SharedHelpers.major_deprecation 2, "Bundler no longer integrates with " \ +Bundler::SharedHelpers.major_deprecation 3, "Bundler no longer integrates with " \ "Capistrano, but Capistrano provides its own integration with " \ "Bundler via the capistrano-bundler gem. Use it instead." diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 6707fc58931..dca87d3c106 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -194,7 +194,7 @@ def path(path, options = {}, &blk) " end\n\n" raise DeprecatedError, msg if Bundler.feature_flag.disable_multisource? - SharedHelpers.major_deprecation(2, msg.strip) + SharedHelpers.major_deprecation(3, msg.strip) end source_options = normalize_hash(options).merge( @@ -306,7 +306,7 @@ def add_git_sources repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") # TODO: 2.0 upgrade this setting to the default if Bundler.feature_flag.github_https? - Bundler::SharedHelpers.major_deprecation 2, "The `github.https` setting will be removed" + Bundler::SharedHelpers.major_deprecation 3, "The `github.https` setting will be removed" "https://github.com/#{repo_name}.git" else "git://github.com/#{repo_name}.git" @@ -454,7 +454,7 @@ def validate_keys(command, opts, valid_keys) def normalize_source(source) case source when :gemcutter, :rubygems, :rubyforge - Bundler::SharedHelpers.major_deprecation 2, "The source :#{source} is deprecated because HTTP " \ + Bundler::SharedHelpers.major_deprecation 3, "The source :#{source} is deprecated because HTTP " \ "requests are insecure.\nPlease change your source to 'https://" \ "rubygems.org' if possible, or 'http://rubygems.org' if not." "http://rubygems.org" @@ -472,13 +472,13 @@ def check_primary_source_safety(source_list) msg = "This Gemfile contains multiple primary sources. " \ "Each source after the first must include a block to indicate which gems " \ "should come from that source" - unless Bundler.feature_flag.bundler_2_mode? + unless Bundler.feature_flag.bundler_3_mode? msg += ". To downgrade this error to a warning, run " \ "`bundle config --delete disable_multisource`" end raise GemfileEvalError, msg else - Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple primary sources. " \ + Bundler::SharedHelpers.major_deprecation 3, "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. " \ @@ -496,8 +496,8 @@ def warn_deprecated_git_source(name, replacement, additional_message = nil) "do |repo_name|\n#{replacement.to_s.gsub(/^/, " ")}\n end" end - Bundler::SharedHelpers.major_deprecation 2, <<-EOS -The :#{name} git source is deprecated, and will be removed in Bundler 2.0.#{additional_message} Add this code to the top of your Gemfile to ensure it continues to work: + Bundler::SharedHelpers.major_deprecation 3, <<-EOS +The :#{name} git source is deprecated, and will be removed in Bundler 3.0.#{additional_message} Add this code to the top of your Gemfile to ensure it continues to work: git_source(:#{name}) #{replacement} diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb index 249170c4b29..e5b4e84063f 100644 --- a/lib/bundler/feature_flag.rb +++ b/lib/bundler/feature_flag.rb @@ -27,38 +27,39 @@ def self.settings_method(name, key, &default) (1..10).each {|v| define_method("bundler_#{v}_mode?") { major_version >= v } } - settings_flag(:allow_bundler_dependency_conflicts) { bundler_2_mode? } - settings_flag(:allow_offline_install) { bundler_2_mode? } - settings_flag(:auto_clean_without_path) { bundler_2_mode? } - settings_flag(:auto_config_jobs) { bundler_2_mode? } - settings_flag(:cache_all) { bundler_2_mode? } - settings_flag(:cache_command_is_package) { bundler_2_mode? } - settings_flag(:console_command) { !bundler_2_mode? } - settings_flag(:default_install_uses_path) { bundler_2_mode? } - settings_flag(:deployment_means_frozen) { bundler_2_mode? } - settings_flag(:disable_multisource) { bundler_2_mode? } + settings_flag(:allow_bundler_dependency_conflicts) { bundler_3_mode? } + settings_flag(:allow_offline_install) { bundler_3_mode? } + settings_flag(:auto_clean_without_path) { bundler_3_mode? } + settings_flag(:auto_config_jobs) { bundler_3_mode? } + settings_flag(:cache_all) { bundler_3_mode? } + settings_flag(:cache_command_is_package) { bundler_3_mode? } + settings_flag(:console_command) { !bundler_3_mode? } + settings_flag(:default_install_uses_path) { bundler_3_mode? } + settings_flag(:deployment_means_frozen) { bundler_3_mode? } + settings_flag(:disable_multisource) { bundler_3_mode? } settings_flag(:error_on_stderr) { bundler_2_mode? } - settings_flag(:forget_cli_options) { bundler_2_mode? } - settings_flag(:global_path_appends_ruby_scope) { bundler_2_mode? } - settings_flag(:global_gem_cache) { bundler_2_mode? } - settings_flag(:init_gems_rb) { bundler_2_mode? } - settings_flag(:list_command) { bundler_2_mode? } - settings_flag(:lockfile_uses_separate_rubygems_sources) { bundler_2_mode? } - settings_flag(:only_update_to_newer_versions) { bundler_2_mode? } - settings_flag(:path_relative_to_cwd) { bundler_2_mode? } + settings_flag(:forget_cli_options) { bundler_3_mode? } + settings_flag(:global_path_appends_ruby_scope) { bundler_3_mode? } + settings_flag(:global_gem_cache) { bundler_3_mode? } + settings_flag(:init_gems_rb) { bundler_3_mode? } + settings_flag(:list_command) { bundler_3_mode? } + settings_flag(:lockfile_uses_separate_rubygems_sources) { bundler_3_mode? } + settings_flag(:lockfile_upgrade_warning) { bundler_3_mode? } + settings_flag(:only_update_to_newer_versions) { bundler_3_mode? } + settings_flag(:path_relative_to_cwd) { bundler_3_mode? } settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") } - settings_flag(:prefer_gems_rb) { bundler_2_mode? } - settings_flag(:print_only_version_number) { bundler_2_mode? } - settings_flag(:setup_makes_kernel_gem_public) { !bundler_2_mode? } - settings_flag(:skip_default_git_sources) { bundler_2_mode? } - settings_flag(:specific_platform) { bundler_2_mode? } - settings_flag(:suppress_install_using_messages) { bundler_2_mode? } - settings_flag(:unlock_source_unlocks_spec) { !bundler_2_mode? } - settings_flag(:update_requires_all_flag) { bundler_2_mode? } - settings_flag(:use_gem_version_promoter_for_major_updates) { bundler_2_mode? } - settings_flag(:viz_command) { !bundler_2_mode? } + settings_flag(:prefer_gems_rb) { bundler_3_mode? } + settings_flag(:print_only_version_number) { bundler_3_mode? } + settings_flag(:setup_makes_kernel_gem_public) { !bundler_3_mode? } + settings_flag(:skip_default_git_sources) { bundler_3_mode? } + settings_flag(:specific_platform) { bundler_3_mode? } + settings_flag(:suppress_install_using_messages) { bundler_3_mode? } + settings_flag(:unlock_source_unlocks_spec) { !bundler_3_mode? } + settings_flag(:update_requires_all_flag) { bundler_3_mode? } + settings_flag(:use_gem_version_promoter_for_major_updates) { bundler_3_mode? } + settings_flag(:viz_command) { !bundler_3_mode? } - settings_option(:default_cli_command) { bundler_2_mode? ? :cli_help : :install } + settings_option(:default_cli_command) { bundler_3_mode? ? :cli_help : :install } settings_method(:github_https?, "github.https") { bundler_2_mode? } diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 783d106e7b7..f088c2fdfba 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -465,7 +465,7 @@ def replace_bin_path(specs, specs_by_name) raise Gem::Exception, "no default executable for #{spec.full_name}" unless exec_name ||= spec.default_executable unless spec.name == gem_name - Bundler::SharedHelpers.major_deprecation 2, + Bundler::SharedHelpers.major_deprecation 3, "Bundler is using a binstub that was created for a different gem (#{spec.name}).\n" \ "You should run `bundle binstub #{gem_name}` " \ "to work around a system/bundle conflict." diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index fe68d510ffa..66af31dab25 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -40,6 +40,7 @@ class Settings ignore_messages init_gems_rb list_command + lockfile_upgrade_warning lockfile_uses_separate_rubygems_sources major_deprecations no_install @@ -112,7 +113,7 @@ def set_command_option(key, value) "bundle config #{key} #{Array(value).join(":")}" end - Bundler::SharedHelpers.major_deprecation 2,\ + Bundler::SharedHelpers.major_deprecation 3,\ "flags passed to commands " \ "will no longer be automatically remembered. Instead please set flags " \ "you want remembered between commands using `bundle config " \ diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index e09e5e8b745..a892fac67f2 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -158,8 +158,8 @@ def print_major_deprecations! next if gemfiles.empty? break false if gemfiles.size == 1 end - if multiple_gemfiles && Bundler.bundler_major_version == 1 - Bundler::SharedHelpers.major_deprecation 2, \ + if multiple_gemfiles && Bundler.bundler_major_version == 2 + Bundler::SharedHelpers.major_deprecation 3, \ "gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock." end diff --git a/lib/bundler/templates/newgem/Gemfile.tt b/lib/bundler/templates/newgem/Gemfile.tt index c114bd66659..4cd2e40f4f8 100644 --- a/lib/bundler/templates/newgem/Gemfile.tt +++ b/lib/bundler/templates/newgem/Gemfile.tt @@ -1,6 +1,4 @@ source "https://rubygems.org" -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } - # Specify your gem's dependencies in <%= config[:name] %>.gemspec gemspec diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb index 75d0817cca8..27815cc478b 100644 --- a/lib/bundler/version.rb +++ b/lib/bundler/version.rb @@ -7,7 +7,7 @@ module Bundler # We're doing this because we might write tests that deal # with other versions of bundler and we are unsure how to # handle this better. - VERSION = "2.0.0.dev" unless defined?(::Bundler::VERSION) + VERSION = "3.0.0.dev" unless defined?(::Bundler::VERSION) def self.overwrite_loaded_gem_version begin diff --git a/lib/bundler/vlad.rb b/lib/bundler/vlad.rb index 68181e7db83..a6b13435c9f 100644 --- a/lib/bundler/vlad.rb +++ b/lib/bundler/vlad.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "bundler/shared_helpers" -Bundler::SharedHelpers.major_deprecation 2, +Bundler::SharedHelpers.major_deprecation 3, "The Bundler task for Vlad" # Vlad task for Bundler. diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb index c82d46587e6..9a2591ac966 100644 --- a/spec/bundler/cli_spec.rb +++ b/spec/bundler/cli_spec.rb @@ -28,7 +28,7 @@ end context "with no arguments" do - it "prints a concise help message", :bundler => "2" do + it "prints a concise help message", :bundler => "3" do bundle! "" expect(last_command.stderr).to be_empty expect(last_command.stdout).to include("Bundler version #{Bundler::VERSION}"). @@ -161,12 +161,12 @@ end RSpec.describe "bundler executable" do - it "shows the bundler version just as the `bundle` executable does", :bundler => "< 2" do + it "shows the bundler version just as the `bundle` executable does", :bundler => "< 3" do bundler "--version" expect(out).to eq("Bundler version #{Bundler::VERSION}") end - it "shows the bundler version just as the `bundle` executable does", :bundler => "2" do + it "shows the bundler version just as the `bundle` executable does", :bundler => "3" do bundler "--version" expect(out).to eq(Bundler::VERSION) end diff --git a/spec/bundler/definition_spec.rb b/spec/bundler/definition_spec.rb index ceb7b4bf05b..a27c5b0a544 100644 --- a/spec/bundler/definition_spec.rb +++ b/spec/bundler/definition_spec.rb @@ -34,7 +34,7 @@ end describe "detects changes" do - it "for a path gem with changes", :bundler => "< 2" do + it "for a path gem with changes", :bundler => "< 3" do build_lib "foo", "1.0", :path => lib_path("foo") install_gemfile <<-G @@ -72,7 +72,7 @@ G end - it "for a path gem with changes", :bundler => "2" do + it "for a path gem with changes", :bundler => "3" do build_lib "foo", "1.0", :path => lib_path("foo") install_gemfile <<-G @@ -110,7 +110,7 @@ G end - it "for a path gem with deps and no changes", :bundler => "< 2" do + it "for a path gem with deps and no changes", :bundler => "< 3" do build_lib "foo", "1.0", :path => lib_path("foo") do |s| s.add_dependency "rack", "1.0" s.add_development_dependency "net-ssh", "1.0" @@ -147,7 +147,7 @@ G end - it "for a path gem with deps and no changes", :bundler => "2" do + it "for a path gem with deps and no changes", :bundler => "3" do build_lib "foo", "1.0", :path => lib_path("foo") do |s| s.add_dependency "rack", "1.0" s.add_development_dependency "net-ssh", "1.0" diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb index 89528eb745e..94d54ad8774 100644 --- a/spec/bundler/dsl_spec.rb +++ b/spec/bundler/dsl_spec.rb @@ -32,7 +32,7 @@ end end - context "default hosts (git, gist)", :bundler => "< 2" do + context "default hosts (git, gist)", :bundler => "< 3" do context "when github.https config is true" do before { bundle "config github.https true" } it "converts :github to :git using https" do @@ -79,7 +79,7 @@ end end - context "default git sources", :bundler => "2" do + context "default git sources", :bundler => "3" do it "has none" do expect(subject.instance_variable_get(:@git_sources)).to eq({}) end @@ -245,7 +245,7 @@ # gem 'spree_api' # gem 'spree_backend' # end - describe "#github", :bundler => "< 2" do + describe "#github", :bundler => "< 3" do it "from github" do spree_gems = %w[spree_core spree_api spree_backend] subject.github "spree" do @@ -258,7 +258,7 @@ end end - describe "#github", :bundler => "2" do + describe "#github", :bundler => "3" do it "from github" do expect do spree_gems = %w[spree_core spree_api spree_backend] diff --git a/spec/bundler/fetcher/compact_index_spec.rb b/spec/bundler/fetcher/compact_index_spec.rb index e0f58766eab..5a2d22193a7 100644 --- a/spec/bundler/fetcher/compact_index_spec.rb +++ b/spec/bundler/fetcher/compact_index_spec.rb @@ -44,7 +44,7 @@ end end - context "when OpenSSL is FIPS-enabled", :ruby => ">= 2.0.0" do + context "when OpenSSL is FIPS-enabled" do def remove_cached_md5_availability return unless Bundler::SharedHelpers.instance_variable_defined?(:@md5_available) Bundler::SharedHelpers.remove_instance_variable(:@md5_available) diff --git a/spec/bundler/friendly_errors_spec.rb b/spec/bundler/friendly_errors_spec.rb index 2a1be491efa..9fff7c01be3 100644 --- a/spec/bundler/friendly_errors_spec.rb +++ b/spec/bundler/friendly_errors_spec.rb @@ -16,7 +16,7 @@ FileUtils.rm(Gem.configuration.config_file_name) end - it "reports a relevant friendly error message", :ruby => ">= 1.9", :rubygems => "< 2.5.0" do + it "reports a relevant friendly error message", :rubygems => "< 2.5.0" do gemfile <<-G source "file://#{gem_repo1}" gem "rack" @@ -31,7 +31,7 @@ expect(exitstatus).to eq(25) if exitstatus end - it "reports a relevant friendly error message", :ruby => ">= 1.9", :rubygems => ">= 2.5.0" do + it "reports a relevant friendly error message", :rubygems => ">= 2.5.0" do gemfile <<-G source "file://#{gem_repo1}" gem "rack" diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb index b66c43fd928..5a6479ed01c 100644 --- a/spec/bundler/shared_helpers_spec.rb +++ b/spec/bundler/shared_helpers_spec.rb @@ -279,7 +279,7 @@ ) end - context "with a jruby path_separator regex", :ruby => "1.9" do + context "with a jruby path_separator regex" do # In versions of jruby that supported ruby 1.8, the path separator was the standard File::PATH_SEPARATOR let(:regex) { Regexp.new("(? "1.9" do + context "system throws Errno::ENOTSUP" do let(:file_op_block) { proc {|_path| raise Errno::ENOTSUP } } it "raises a OperationNotSupportedError" do diff --git a/spec/bundler/source_list_spec.rb b/spec/bundler/source_list_spec.rb index ce3353012c8..541a46c6d01 100644 --- a/spec/bundler/source_list_spec.rb +++ b/spec/bundler/source_list_spec.rb @@ -115,7 +115,7 @@ end end - describe "#add_rubygems_remote", :bundler => "< 2" do + describe "#add_rubygems_remote", :bundler => "< 3" do let!(:returned_source) { source_list.add_rubygems_remote("https://rubygems.org/") } it "returns the aggregate rubygems source" do @@ -372,7 +372,7 @@ source_list.add_git_source("uri" => "git://first-git.org/path.git") end - it "combines the rubygems sources into a single instance, removing duplicate remotes from the end", :bundler => "< 2" do + it "combines the rubygems sources into a single instance, removing duplicate remotes from the end", :bundler => "< 3" do expect(source_list.lock_sources).to eq [ Bundler::Source::Git.new("uri" => "git://first-git.org/path.git"), Bundler::Source::Git.new("uri" => "git://second-git.org/path.git"), @@ -391,7 +391,7 @@ ] end - it "returns all sources, without combining rubygems sources", :bundler => "2" do + it "returns all sources, without combining rubygems sources", :bundler => "3" do expect(source_list.lock_sources).to eq [ Bundler::Source::Rubygems.new, Bundler::Source::Rubygems.new("remotes" => ["https://duplicate-rubygems.org"]), diff --git a/spec/bundler/ui/shell_spec.rb b/spec/bundler/ui/shell_spec.rb index 951a446aff5..23a7670dd1d 100644 --- a/spec/bundler/ui/shell_spec.rb +++ b/spec/bundler/ui/shell_spec.rb @@ -21,11 +21,7 @@ describe "#warn" do before { subject.level = "warn" } - it "prints to stdout", :bundler => "< 2" do - expect { subject.warn("warning") }.to output("warning\n").to_stdout - end - - it "prints to stderr", :bundler => "2" do + it "prints to stderr" do expect { subject.warn("warning") }.to output("warning\n").to_stderr end @@ -46,11 +42,7 @@ describe "#error" do before { subject.level = "error" } - it "prints to stdout", :bundler => "< 2" do - expect { subject.error("error!!!") }.to output("error!!!\n").to_stdout - end - - it "prints to stderr", :bundler => "2" do + it "prints to stderr" do expect { subject.error("error!!!") }.to output("error!!!\n").to_stderr end diff --git a/spec/bundler/ui_spec.rb b/spec/bundler/ui_spec.rb index 6ef8729277a..6df0d2e2901 100644 --- a/spec/bundler/ui_spec.rb +++ b/spec/bundler/ui_spec.rb @@ -2,7 +2,7 @@ RSpec.describe Bundler::UI do describe Bundler::UI::Silent do - it "has the same instance methods as Shell", :ruby => ">= 1.9" do + it "has the same instance methods as Shell" do shell = Bundler::UI::Shell methods = proc do |cls| cls.instance_methods.map do |i| @@ -13,7 +13,7 @@ expect(methods.call(described_class)).to eq(methods.call(shell)) end - it "has the same instance class as Shell", :ruby => ">= 1.9" do + it "has the same instance class as Shell" do shell = Bundler::UI::Shell methods = proc do |cls| cls.methods.map do |i| diff --git a/spec/cache/gems_spec.rb b/spec/cache/gems_spec.rb index 4a0b953830b..9fbd74801db 100644 --- a/spec/cache/gems_spec.rb +++ b/spec/cache/gems_spec.rb @@ -83,7 +83,7 @@ it_behaves_like "when there are only gemsources" end - describe "when there is a built-in gem", :ruby => "2.0" do + describe "when there is a built-in gem" do before :each do build_repo2 do build_gem "builtin_gem", "1.0.2" diff --git a/spec/cache/git_spec.rb b/spec/cache/git_spec.rb index 33387dbbb21..80f41912957 100644 --- a/spec/cache/git_spec.rb +++ b/spec/cache/git_spec.rb @@ -168,7 +168,7 @@ expect(the_bundle).to include_gems "has_submodule 1.0" end - it "displays warning message when detecting git repo in Gemfile", :bundler => "< 2" do + it "displays warning message when detecting git repo in Gemfile", :bundler => "< 3" do build_git "foo" install_gemfile <<-G diff --git a/spec/cache/path_spec.rb b/spec/cache/path_spec.rb index 8c6a8434760..12be2dbcf89 100644 --- a/spec/cache/path_spec.rb +++ b/spec/cache/path_spec.rb @@ -86,7 +86,7 @@ expect(bundled_app("vendor/cache/bar-1.0")).not_to exist end - it "raises a warning without --all", :bundler => "< 2" do + it "raises a warning without --all", :bundler => "< 3" do build_lib "foo" install_gemfile <<-G diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index 2f014f26313..26bbb17b754 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -294,7 +294,7 @@ expect(bundled_app("exec/rackup")).to exist end - it "setting is saved for bundle install", :bundler => "< 2" do + it "setting is saved for bundle install", :bundler => "< 3" do install_gemfile <<-G source "file://#{gem_repo1}" gem "rack" diff --git a/spec/commands/check_spec.rb b/spec/commands/check_spec.rb index f2af446fbf0..890f4b13564 100644 --- a/spec/commands/check_spec.rb +++ b/spec/commands/check_spec.rb @@ -92,7 +92,7 @@ expect(out).to include("Bundler can't satisfy your Gemfile's dependencies.") end - it "remembers --without option from install", :bundler => "< 2" do + it "remembers --without option from install", :bundler => "< 3" do gemfile <<-G source "file://#{gem_repo1}" group :foo do @@ -238,7 +238,7 @@ expect(last_command).to be_failure end - context "--path", :bundler => "< 2" do + context "--path", :bundler => "< 3" do before do gemfile <<-G source "file://#{gem_repo1}" @@ -254,7 +254,7 @@ expect(out).to include("The Gemfile's dependencies are satisfied") end - it "should write to .bundle/config", :bundler => "< 2" do + it "should write to .bundle/config", :bundler => "< 3" do bundle "check --path vendor/bundle" bundle! "check" end diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb index 37cbeeb4e7c..158d58d67c4 100644 --- a/spec/commands/clean_spec.rb +++ b/spec/commands/clean_spec.rb @@ -142,7 +142,7 @@ def should_not_have_gems(*gems) bundle :clean digest = Digest(:SHA1).hexdigest(git_path.to_s) - cache_path = Bundler::VERSION.start_with?("1.") ? vendored_gems("cache/bundler/git/foo-1.0-#{digest}") : home(".bundle/cache/git/foo-1.0-#{digest}") + cache_path = Bundler.bundler_major_version < 3 ? vendored_gems("cache/bundler/git/foo-1.0-#{digest}") : home(".bundle/cache/git/foo-1.0-#{digest}") expect(cache_path).to exist end @@ -343,7 +343,7 @@ def should_not_have_gems(*gems) expect(out).to include("rack (1.0.0)").and include("thin (1.0)") end - it "--clean should override the bundle setting on install", :bundler => "< 2" do + it "--clean should override the bundle setting on install", :bundler => "< 3" do gemfile <<-G source "file://#{gem_repo1}" @@ -363,7 +363,7 @@ def should_not_have_gems(*gems) should_not_have_gems "thin-1.0" end - it "--clean should override the bundle setting on update", :bundler => "< 2" do + it "--clean should override the bundle setting on update", :bundler => "< 3" do build_repo2 gemfile <<-G @@ -383,7 +383,7 @@ def should_not_have_gems(*gems) should_not_have_gems "foo-1.0" end - it "automatically cleans when path has not been set", :bundler => "2" do + it "automatically cleans when path has not been set", :bundler => "3" do build_repo2 install_gemfile! <<-G diff --git a/spec/commands/config_spec.rb b/spec/commands/config_spec.rb index 61734ef0052..03b18843bc7 100644 --- a/spec/commands/config_spec.rb +++ b/spec/commands/config_spec.rb @@ -20,8 +20,8 @@ context "with global config" do it "prints config assigned to local scope" do - bundle "config --local foo bar2" - bundle "config --parseable" + bundle "config set --local foo bar2" + bundle "config list --parseable" expect(out).to include("foo=bar2") end end @@ -110,16 +110,16 @@ end it "can be deleted" do - bundle "config --global foo global" - bundle "config --delete foo" + bundle "config set --global foo global" + bundle "config unset foo" run "puts Bundler.settings[:foo] == nil" expect(out).to eq("true") end it "warns when overriding" do - bundle "config --global foo previous" - bundle "config --global foo global" + bundle "config set --global foo previous" + bundle "config set --global foo global" expect(out).to match(/You are replacing the current global value of foo/) run "puts Bundler.settings[:foo]" @@ -142,7 +142,7 @@ end it "saves with parseable option" do - bundle "config --global --parseable foo value" + bundle "config set --global --parseable foo value" expect(out).to eq("foo=value") run "puts Bundler.settings['foo']" expect(out).to eq("value") @@ -151,7 +151,7 @@ context "when replacing a current value with the parseable flag" do before { bundle "config --global foo value" } it "prints the current value in a parseable format" do - bundle "config --global --parseable foo value2" + bundle "config set --global --parseable foo value2" expect(out).to eq "foo=value2" run "puts Bundler.settings['foo']" expect(out).to eq("value2") @@ -186,16 +186,16 @@ end it "can be deleted" do - bundle "config --local foo local" - bundle "config --delete foo" + bundle "config set --local foo local" + bundle "config unset foo" run "puts Bundler.settings[:foo] == nil" expect(out).to eq("true") end it "warns when overriding" do - bundle "config --local foo previous" - bundle "config --local foo local" + bundle "config set --local foo previous" + bundle "config set --local foo local" expect(out).to match(/You are replacing the current local value of foo/) run "puts Bundler.settings[:foo]" @@ -209,8 +209,8 @@ end it "can be deleted with parseable option" do - bundle "config --local foo value" - bundle "config --delete --parseable foo" + bundle "config set --local foo value" + bundle "config unset --parseable foo" expect(out).to eq "" run "puts Bundler.settings['foo'] == nil" expect(out).to eq("true") @@ -262,29 +262,29 @@ describe "parseable option" do it "prints an empty string" do - bundle "config foo --parseable" + bundle "config get foo --parseable" expect(out).to eq "" end it "only prints the value of the config" do - bundle "config foo local" - bundle "config foo --parseable" + bundle "config set foo local" + bundle "config get --parseable foo" expect(out).to eq "foo=local" end it "can print global config" do - bundle "config --global bar value" - bundle "config bar --parseable" + bundle "config set --global bar value" + bundle "config get --parseable bar" expect(out).to eq "bar=value" end it "prefers local config over global" do - bundle "config --local bar value2" - bundle "config --global bar value" - bundle "config bar --parseable" + bundle "config set --local bar value2" + bundle "config set --global bar value" + bundle "config get bar --parseable" expect(out).to eq "bar=value2" end @@ -322,7 +322,7 @@ expect(out).to eq("something'") end - it "doesn't return quotes around values", :ruby => "1.9" do + it "doesn't return quotes around values" do bundle "config foo '1'" run "puts Bundler.settings.send(:global_config_file).read" expect(out).to include('"1"') @@ -330,7 +330,7 @@ expect(out).to eq("1") end - it "doesn't duplicate quotes around values", :if => (RUBY_VERSION >= "2.1") do + it "doesn't duplicate quotes around values" do bundled_app(".bundle").mkpath File.open(bundled_app(".bundle/config"), "w") do |f| f.write 'BUNDLE_FOO: "$BUILD_DIR"' diff --git a/spec/commands/console_spec.rb b/spec/commands/console_spec.rb index 9bf66e8f5b9..05b0a6c1e42 100644 --- a/spec/commands/console_spec.rb +++ b/spec/commands/console_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "bundle console", :bundler => "< 2" do +RSpec.describe "bundle console", :bundler => "< 3" do before :each do install_gemfile <<-G source "file://#{gem_repo1}" diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index 7503b9db5f0..c3e181a761c 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -570,22 +570,7 @@ def bin_path(a,b,c) it_behaves_like "it runs" end - context "the executable is empty", :bundler => "< 2" do - let(:executable) { "" } - - let(:exit_code) { 0 } - let(:expected) { "#{path} is empty" } - let(:expected_err) { "" } - if LessThanProc.with(RUBY_VERSION).call("1.9") - # Kernel#exec in ruby < 1.9 will raise Errno::ENOEXEC if the command content is empty, - # even if the command is set as an executable. - pending "Kernel#exec is different" - else - it_behaves_like "it runs" - end - end - - context "the executable is empty", :bundler => "2" do + context "the executable is empty" do let(:executable) { "" } let(:exit_code) { 0 } @@ -594,18 +579,7 @@ def bin_path(a,b,c) it_behaves_like "it runs" end - context "the executable raises", :bundler => "< 2" do - let(:executable) { super() << "\nraise 'ERROR'" } - let(:exit_code) { 1 } - let(:expected) { super() << "\nbundler: failed to load command: #{path} (#{path})" } - let(:expected_err) do - "RuntimeError: ERROR\n #{path}:10" + - (Bundler.current_ruby.ruby_18? ? "" : ":in `'") - end - it_behaves_like "it runs" - end - - context "the executable raises", :bundler => "2" do + context "the executable raises" do let(:executable) { super() << "\nraise 'ERROR'" } let(:exit_code) { 1 } let(:expected_err) do @@ -615,16 +589,7 @@ def bin_path(a,b,c) it_behaves_like "it runs" end - context "the executable raises an error without a backtrace", :bundler => "< 2" do - let(:executable) { super() << "\nclass Err < Exception\ndef backtrace; end;\nend\nraise Err" } - let(:exit_code) { 1 } - let(:expected) { super() << "\nbundler: failed to load command: #{path} (#{path})" } - let(:expected_err) { "Err: Err" } - - it_behaves_like "it runs" - end - - context "the executable raises an error without a backtrace", :bundler => "2" do + context "the executable raises an error without a backtrace" do let(:executable) { super() << "\nclass Err < Exception\ndef backtrace; end;\nend\nraise Err" } let(:exit_code) { 1 } let(:expected_err) { "bundler: failed to load command: #{path} (#{path})\nErr: Err" } @@ -638,7 +603,7 @@ def bin_path(a,b,c) it_behaves_like "it runs" end - context "when Bundler.setup fails", :bundler => "< 2" do + context "when Bundler.setup fails", :bundler => "< 3" do before do gemfile <<-G gem 'rack', '2' @@ -655,7 +620,7 @@ def bin_path(a,b,c) it_behaves_like "it runs" end - context "when Bundler.setup fails", :bundler => "2" do + context "when Bundler.setup fails", :bundler => "3" do before do gemfile <<-G gem 'rack', '2' @@ -751,7 +716,7 @@ def bin_path(a,b,c) end RUBY - it "receives the signal", :ruby => ">= 1.9.3" do + it "receives the signal" do bundle!("exec #{path}") do |_, o, thr| o.gets # Consumes 'Started' and ensures that thread has started Process.kill("INT", thr.pid) diff --git a/spec/commands/init_spec.rb b/spec/commands/init_spec.rb index 9b5bd958145..8a8f0effa07 100644 --- a/spec/commands/init_spec.rb +++ b/spec/commands/init_spec.rb @@ -1,19 +1,19 @@ # frozen_string_literal: true RSpec.describe "bundle init" do - it "generates a Gemfile", :bundler => "< 2" do + it "generates a Gemfile", :bundler => "< 3" do bundle! :init expect(out).to include("Writing new Gemfile") expect(bundled_app("Gemfile")).to be_file end - it "generates a gems.rb", :bundler => "2" do + it "generates a gems.rb", :bundler => "3" do bundle! :init expect(out).to include("Writing new gems.rb") expect(bundled_app("gems.rb")).to be_file end - context "when a Gemfile already exists", :bundler => "< 2" do + context "when a Gemfile already exists", :bundler => "< 3" do before do create_file "Gemfile", <<-G gem "rails" @@ -30,7 +30,7 @@ end end - context "when gems.rb already exists", :bundler => ">= 2" do + context "when gems.rb already exists", :bundler => ">= 3" do before do create_file("gems.rb", <<-G) gem "rails" @@ -47,7 +47,7 @@ end end - context "when a Gemfile exists in a parent directory", :bundler => "< 2" do + context "when a Gemfile exists in a parent directory", :bundler => "< 3" do let(:subdir) { "child_dir" } it "lets users generate a Gemfile in a child directory" do @@ -82,7 +82,7 @@ end end - context "when a gems.rb file exists in a parent directory", :bundler => ">= 2" do + context "when a gems.rb file exists in a parent directory", :bundler => ">= 3" do let(:subdir) { "child_dir" } it "lets users generate a Gemfile in a child directory" do @@ -99,7 +99,7 @@ end end - context "given --gemspec option", :bundler => "< 2" do + context "given --gemspec option", :bundler => "< 3" do let(:spec_file) { tmp.join("test.gemspec") } it "should generate from an existing gemspec" do @@ -115,7 +115,7 @@ bundle :init, :gemspec => spec_file - gemfile = if Bundler::VERSION[0, 2] == "1." + gemfile = if Bundler::VERSION[0, 2].to_i < 3 bundled_app("Gemfile").read else bundled_app("gems.rb").read @@ -146,7 +146,7 @@ context "when init_gems_rb setting is enabled" do before { bundle "config init_gems_rb true" } - context "given --gemspec option", :bundler => "< 2" do + context "given --gemspec option", :bundler => "< 3" do let(:spec_file) { tmp.join("test.gemspec") } before do diff --git a/spec/commands/inject_spec.rb b/spec/commands/inject_spec.rb index b7ffc89a341..d091e01380d 100644 --- a/spec/commands/inject_spec.rb +++ b/spec/commands/inject_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "bundle inject", :bundler => "< 2" do +RSpec.describe "bundle inject", :bundler => "< 3" do before :each do gemfile <<-G source "file://#{gem_repo1}" @@ -79,7 +79,7 @@ context "when frozen" do before do bundle "install" - if Bundler.feature_flag.bundler_2_mode? + if Bundler.feature_flag.bundler_3_mode? bundle! "config --local deployment true" else bundle! "config --local frozen true" diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb index 394f672fef7..326f98161ef 100644 --- a/spec/commands/install_spec.rb +++ b/spec/commands/install_spec.rb @@ -29,7 +29,7 @@ expect(bundled_app("Gemfile.lock")).to exist end - it "does not create ./.bundle by default", :bundler => "< 2" do + it "does not create ./.bundle by default", :bundler => "< 3" do gemfile <<-G source "file://#{gem_repo1}" gem "rack" @@ -275,14 +275,14 @@ expect(the_bundle).to include_gems "rack 1.0" end - it "allows running bundle install --system without deleting foo", :bundler => "< 2" do + it "allows running bundle install --system without deleting foo", :bundler => "< 3" do bundle "install", forgotten_command_line_options(:path => "vendor") bundle "install", forgotten_command_line_options(:system => true) FileUtils.rm_rf(bundled_app("vendor")) expect(the_bundle).to include_gems "rack 1.0" end - it "allows running bundle install --system after deleting foo", :bundler => "< 2" do + it "allows running bundle install --system after deleting foo", :bundler => "< 3" do bundle "install", forgotten_command_line_options(:path => "vendor") FileUtils.rm_rf(bundled_app("vendor")) bundle "install", forgotten_command_line_options(:system => true) @@ -290,7 +290,7 @@ end end - it "finds gems in multiple sources", :bundler => "< 2" do + it "finds gems in multiple sources", :bundler => "< 3" do build_repo2 update_repo2 diff --git a/spec/commands/list_spec.rb b/spec/commands/list_spec.rb index 5305176c655..ba4bb9b0408 100644 --- a/spec/commands/list_spec.rb +++ b/spec/commands/list_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "bundle list", :bundler => "2" do +RSpec.describe "bundle list", :bundler => "3" do before do install_gemfile <<-G source "file://#{gem_repo1}" diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb index 394db664d8c..24008938c36 100644 --- a/spec/commands/outdated_spec.rb +++ b/spec/commands/outdated_spec.rb @@ -419,7 +419,7 @@ def test_group_option(group = nil, gems_list_size = 1) expect(out).to include("Installing foo 1.0") end - context "after bundle install --deployment", :bundler => "< 2" do + context "after bundle install --deployment", :bundler => "< 3" do before do install_gemfile <<-G, forgotten_command_line_options(:deployment => true) source "file://#{gem_repo2}" diff --git a/spec/commands/package_spec.rb b/spec/commands/package_spec.rb index 6351909bc7d..a31de0cb19c 100644 --- a/spec/commands/package_spec.rb +++ b/spec/commands/package_spec.rb @@ -141,7 +141,7 @@ end end - context "with --path", :bundler => "< 2" do + context "with --path", :bundler => "< 3" do it "sets root directory for gems" do gemfile <<-D source "file://#{gem_repo1}" @@ -182,7 +182,7 @@ end context "with --all-platforms" do - it "puts the gems in vendor/cache even for other rubies", :ruby => "2.1" do + it "puts the gems in vendor/cache even for other rubies" do gemfile <<-D source "file://#{gem_repo1}" gem 'rack', :platforms => :ruby_19 diff --git a/spec/commands/pristine_spec.rb b/spec/commands/pristine_spec.rb index a868465c031..d8761bba26d 100644 --- a/spec/commands/pristine_spec.rb +++ b/spec/commands/pristine_spec.rb @@ -48,7 +48,14 @@ bundle! "install" bundle! "pristine", :system_bundler => true bundle! "-v", :system_bundler => true - expect(out).to end_with(Bundler::VERSION) + + expected = if Bundler::VERSION < "3.0" + "Bundler version" + else + Bundler::VERSION + end + + expect(out).to start_with(expected) end end diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb index 102b9534de5..40c4846d41c 100644 --- a/spec/commands/show_spec.rb +++ b/spec/commands/show_spec.rb @@ -25,20 +25,54 @@ expect(bundled_app("Gemfile.lock")).to exist end - it "prints path if gem exists in bundle", :bundler => "< 2" do + it "prints path if gem exists in bundle", :bundler => "< 3" do bundle "show rails" expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s) end - it "prints path if gem exists in bundle", :bundler => "2" do - bundle "show rails" - expect(out).to eq( - "[DEPRECATED FOR 2.0] use `bundle info rails` instead of `bundle show rails`\n" + - default_bundle_path("gems", "rails-2.3.2").to_s - ) + context "when show command deprecation is enabled" do + before { bundle "config major_deprecations yes" } + + it "prints path if gem exists in bundle" do + bundle "show rails" + expect(out).to eq( + "[DEPRECATED FOR 3.0] use `bundle info rails` instead of `bundle show rails`\n" + + default_bundle_path("gems", "rails-2.3.2").to_s + ) + end + + it "prints the path to the running bundler" do + bundle "show bundler" + expect(out).to eq( + "[DEPRECATED FOR 3.0] use `bundle info bundler` instead of `bundle show bundler`\n" + + root.to_s + ) + end + + it "prints path if gem exists in bundle (with --paths option)" do + bundle "show rails --paths" + expect(out).to eq( + "[DEPRECATED FOR 3.0] use `bundle info rails --path` instead of `bundle show rails --paths`\n" + + default_bundle_path("gems", "rails-2.3.2").to_s + ) + end + + it "prints path of all gems in bundle sorted by name" do + bundle "show --paths" + + expect(out).to include(default_bundle_path("gems", "rake-10.0.2").to_s) + expect(out).to include(default_bundle_path("gems", "rails-2.3.2").to_s) + + out_lines = out.split("\n") + expect(out_lines[0]).to eq("[DEPRECATED FOR 3.0] use `bundle list` instead of `bundle show --paths`") + + # Gem names are the last component of their path. + gem_list = out_lines[1..-1].map {|p| p.split("/").last } + expect(gem_list).to eq(gem_list.sort) + end end - it "prints path if gem exists in bundle (with --paths option)", :bundler => "< 2" do + it "prints path if gem exists in bundle (with --paths option)", :bundler => "< 3" do bundle "show rails --paths" expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s) end @@ -46,7 +80,7 @@ it "prints path if gem exists in bundle (with --paths option)", :bundler => "2" do bundle "show rails --paths" expect(out).to eq( - "[DEPRECATED FOR 2.0] use `bundle info rails --path` instead of `bundle show rails --paths`\n" + + "[DEPRECATED FOR 3.0] use `bundle info rails --path` instead of `bundle show rails --paths`\n" + default_bundle_path("gems", "rails-2.3.2").to_s ) end @@ -60,15 +94,15 @@ and include(default_bundle_path("gems", "rails-2.3.2").to_s) end - it "prints the path to the running bundler", :bundler => "< 2" do + it "prints the path to the running bundler", :bundler => "< 3" do bundle "show bundler" expect(out).to eq(root.to_s) end - it "prints the path to the running bundler", :bundler => "2" do + it "prints the path to the running bundler", :bundler => "3" do bundle "show bundler" expect(out).to eq( - "[DEPRECATED FOR 2.0] use `bundle info bundler` instead of `bundle show bundler`\n" + + "[DEPRECATED FOR 3.0] use `bundle info bundler` instead of `bundle show bundler`\n" + root.to_s ) end @@ -78,7 +112,7 @@ expect(out).to match(/could not find gem 'missing'/i) end - it "prints path of all gems in bundle sorted by name", :bundler => "< 2" do + it "prints path of all gems in bundle sorted by name", :bundler => "< 3" do bundle "show --paths" expect(out).to include(default_bundle_path("gems", "rake-10.0.2").to_s) @@ -89,14 +123,14 @@ expect(gem_list).to eq(gem_list.sort) end - it "prints path of all gems in bundle sorted by name", :bundler => "2" do + it "prints path of all gems in bundle sorted by name", :bundler => "3" do bundle "show --paths" expect(out).to include(default_bundle_path("gems", "rake-10.0.2").to_s) expect(out).to include(default_bundle_path("gems", "rails-2.3.2").to_s) out_lines = out.split("\n") - expect(out_lines[0]).to eq("[DEPRECATED FOR 2.0] use `bundle list` instead of `bundle show --paths`") + expect(out_lines[0]).to eq("[DEPRECATED FOR 3.0] use `bundle list` instead of `bundle show --paths`") # Gem names are the last component of their path. gem_list = out_lines[1..-1].map {|p| p.split("/").last } diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb index 6f29032dd2b..786719f50d8 100644 --- a/spec/commands/update_spec.rb +++ b/spec/commands/update_spec.rb @@ -12,7 +12,7 @@ G end - describe "with no arguments", :bundler => "< 2" do + describe "with no arguments", :bundler => "< 3" do it "updates the entire bundle" do update_repo2 do build_gem "activesupport", "3.0" @@ -35,7 +35,7 @@ end end - describe "with --all", :bundler => "2" do + describe "with --all", :bundler => "3" do it "updates the entire bundle" do update_repo2 do build_gem "activesupport", "3.0" @@ -280,7 +280,7 @@ end describe "in a frozen bundle" do - it "should fail loudly", :bundler => "< 2" do + it "should fail loudly", :bundler => "< 3" do bundle! "install --deployment" bundle "update", :all => bundle_update_requires_all? @@ -289,14 +289,14 @@ expect(out).to match(/freeze \nby running `bundle install --no-deployment`./m) end - it "should suggest different command when frozen is set globally", :bundler => "< 2" do + it "should suggest different command when frozen is set globally", :bundler => "< 3" do bundle! "config --global frozen 1" bundle "update", :all => bundle_update_requires_all? expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m). and match(/freeze \nby running `bundle config --delete frozen`./m) end - it "should suggest different command when frozen is set globally", :bundler => "2" do + it "should suggest different command when frozen is set globally", :bundler => "3" do bundle! "config --global deployment true" bundle "update", :all => bundle_update_requires_all? expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m). @@ -305,7 +305,7 @@ end describe "with --source option" do - it "should not update gems not included in the source that happen to have the same name", :bundler => "< 2" do + it "should not update gems not included in the source that happen to have the same name", :bundler => "< 3" do install_gemfile! <<-G source "file://#{gem_repo2}" gem "activesupport" @@ -316,7 +316,7 @@ expect(the_bundle).to include_gem "activesupport 3.0" end - it "should not update gems not included in the source that happen to have the same name", :bundler => "2" do + it "should not update gems not included in the source that happen to have the same name", :bundler => "3" do install_gemfile! <<-G source "file://#{gem_repo2}" gem "activesupport" @@ -359,7 +359,7 @@ G end - it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "< 2" do + it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "< 3" do update_repo2 do build_gem "fred", "2.0" build_gem "harry", "2.0" do |s| @@ -372,7 +372,7 @@ expect(the_bundle).to include_gems "fred 1.0" end - it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "2" do + it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "3" do update_repo2 do build_gem "fred", "2.0" build_gem "harry", "2.0" do |s| @@ -404,7 +404,7 @@ G end - it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "< 2" do + it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "< 3" do update_repo2 do build_gem "george", "2.0" build_gem "harry", "2.0" do |s| @@ -418,7 +418,7 @@ expect(the_bundle).to include_gems "george 1.0" end - it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "2" do + it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "3" do update_repo2 do build_gem "george", "2.0" build_gem "harry", "2.0" do |s| @@ -562,14 +562,14 @@ G end - it "should explain that bundler conflicted", :bundler => "< 2" do + it "should explain that bundler conflicted", :bundler => "< 3" do bundle "update", :all => bundle_update_requires_all? expect(last_command.stdboth).not_to match(/in snapshot/i) expect(last_command.bundler_err).to match(/current Bundler version/i). and match(/perhaps you need to update bundler/i) end - it "should warn that the newer version of Bundler would conflict", :bundler => "2" do + it "should warn that the newer version of Bundler would conflict", :bundler => "3" do bundle! "update", :all => true expect(last_command.bundler_err).to include("rails (3.0.1) has dependency bundler"). and include("so the dependency is being ignored") @@ -578,7 +578,7 @@ end RSpec.describe "bundle update" do - it "shows the previous version of the gem when updated from rubygems source", :bundler => "< 2" do + it "shows the previous version of the gem when updated from rubygems source", :bundler => "< 3" do build_repo2 install_gemfile <<-G diff --git a/spec/commands/version_spec.rb b/spec/commands/version_spec.rb index b919c25e0f0..66c79303974 100644 --- a/spec/commands/version_spec.rb +++ b/spec/commands/version_spec.rb @@ -2,36 +2,36 @@ RSpec.describe "bundle version" do context "with -v" do - it "outputs the version", :bundler => "< 2" do + it "outputs the version", :bundler => "< 3" do bundle! "-v" expect(out).to eq("Bundler version #{Bundler::VERSION}") end - it "outputs the version", :bundler => "2" do + it "outputs the version", :bundler => "3" do bundle! "-v" expect(out).to eq(Bundler::VERSION) end end context "with --version" do - it "outputs the version", :bundler => "< 2" do + it "outputs the version", :bundler => "< 3" do bundle! "--version" expect(out).to eq("Bundler version #{Bundler::VERSION}") end - it "outputs the version", :bundler => "2" do + it "outputs the version", :bundler => "3" do bundle! "--version" expect(out).to eq(Bundler::VERSION) end end context "with version" do - it "outputs the version with build metadata", :bundler => "< 2" do + it "outputs the version with build metadata", :bundler => "< 3" do bundle! "version" expect(out).to match(/\ABundler version #{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit [a-fA-F0-9]{7,}\)\z/) end - it "outputs the version with build metadata", :bundler => "2" do + it "outputs the version with build metadata", :bundler => "3" do bundle! "version" expect(out).to match(/\A#{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit [a-fA-F0-9]{7,}\)\z/) end diff --git a/spec/commands/viz_spec.rb b/spec/commands/viz_spec.rb index 3804d3561c2..106ed4173c6 100644 --- a/spec/commands/viz_spec.rb +++ b/spec/commands/viz_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "bundle viz", :ruby => "1.9.3", :bundler => "< 2", :if => Bundler.which("dot") do +RSpec.describe "bundle viz", :if => Bundler.which("dot") do let(:ruby_graphviz) do graphviz_glob = base_system_gems.join("cache/ruby-graphviz*") Pathname.glob(graphviz_glob).first @@ -21,7 +21,7 @@ expect(out).to include("gem_graph.png") bundle! "viz", :format => "debug" - expect(out).to eq(strip_whitespace(<<-DOT).strip) + expect(last_command.stdout).to eq(strip_whitespace(<<-DOT).strip) digraph Gemfile { concentrate = "true"; normalize = "true"; @@ -55,7 +55,7 @@ expect(out).to include("gem_graph.png") bundle! "viz", :format => :debug, :version => true - expect(out).to eq(strip_whitespace(<<-EOS).strip) + expect(last_command.stdout).to eq(strip_whitespace(<<-EOS).strip) digraph Gemfile { concentrate = "true"; normalize = "true"; @@ -93,7 +93,7 @@ G bundle! "viz", :format => "debug" - expect(out).to eq(strip_whitespace(<<-DOT).strip) + expect(last_command.stdout).to eq(strip_whitespace(<<-DOT).strip) digraph Gemfile { concentrate = "true"; normalize = "true"; diff --git a/spec/install/binstubs_spec.rb b/spec/install/binstubs_spec.rb index 23eb691ab86..f04d3fe6548 100644 --- a/spec/install/binstubs_spec.rb +++ b/spec/install/binstubs_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "bundle install", :bundler => "< 2" do +RSpec.describe "bundle install", :bundler => "< 3" do describe "when system_bindir is set" do # On OS X, Gem.bindir defaults to /usr/bin, so system_bindir is useful if # you want to avoid sudo installs for system gems with OS X's default ruby @@ -20,7 +20,7 @@ def Gem.bindir; "/usr/bin"; end end end - describe "when multiple gems contain the same exe", :bundler => "< 2" do + describe "when multiple gems contain the same exe", :bundler => "< 3" do before do build_repo2 do build_gem "fake", "14" do |s| diff --git a/spec/install/bundler_spec.rb b/spec/install/bundler_spec.rb index 42863ed89b4..8c4b95f7573 100644 --- a/spec/install/bundler_spec.rb +++ b/spec/install/bundler_spec.rb @@ -125,7 +125,7 @@ expect(last_command.bundler_err).to include(nice_error) end - it "can install dependencies with newer bundler version with system gems", :ruby => "> 2" do + it "can install dependencies with newer bundler version with system gems" do bundle! "config path.system true" install_gemfile! <<-G source "file://#{gem_repo2}" @@ -138,7 +138,7 @@ expect(out).to include("The Gemfile's dependencies are satisfied") end - it "can install dependencies with newer bundler version with a local path", :ruby => "> 2" do + it "can install dependencies with newer bundler version with a local path" do bundle! "config path .bundle" bundle! "config global_path_appends_ruby_scope true" install_gemfile! <<-G diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb index 3b9d68982ad..b37ac58cd18 100644 --- a/spec/install/deploy_spec.rb +++ b/spec/install/deploy_spec.rb @@ -8,7 +8,7 @@ G end - context "with CLI flags", :bundler => "< 2" do + context "with CLI flags", :bundler => "< 3" do it "fails without a lockfile and says that --deployment requires a lock" do bundle "install --deployment" expect(out).to include("The --deployment flag requires a Gemfile.lock") @@ -109,11 +109,11 @@ bundle "install" end - it "works with the --deployment flag if you didn't change anything", :bundler => "< 2" do + it "works with the --deployment flag if you didn't change anything", :bundler => "< 3" do bundle! "install --deployment" end - it "works with the --frozen flag if you didn't change anything", :bundler => "< 2" do + it "works with the --frozen flag if you didn't change anything", :bundler => "< 3" do bundle! "install --frozen" end @@ -165,7 +165,7 @@ expect(out).to include("The path `#{lib_path("path_gem-1.0")}` does not exist.") end - it "can have --frozen set via an environment variable", :bundler => "< 2" do + it "can have --frozen set via an environment variable", :bundler => "< 3" do gemfile <<-G source "file://#{gem_repo1}" gem "rack" @@ -212,7 +212,7 @@ expect(out).not_to include("* rack-obama") end - it "explodes with the --frozen flag if you make a change and don't check in the lockfile", :bundler => "< 2" do + it "explodes with the --frozen flag if you make a change and don't check in the lockfile", :bundler => "< 3" do gemfile <<-G source "file://#{gem_repo1}" gem "rack" @@ -297,7 +297,7 @@ context "when replacing a host with the same host with credentials" do let(:success_message) do - if Bundler::VERSION.split(".", 2).first == "1" + if Bundler.bundler_major_version < 3 "Could not reach host localgemserver.test" else "Bundle complete!" diff --git a/spec/install/gemfile/gemspec_spec.rb b/spec/install/gemfile/gemspec_spec.rb index 833b4098013..b2503eaba72 100644 --- a/spec/install/gemfile/gemspec_spec.rb +++ b/spec/install/gemfile/gemspec_spec.rb @@ -447,7 +447,7 @@ end end - context "on ruby", :bundler => "< 2" do + context "on ruby", :bundler => "< 3" do before do simulate_platform("ruby") bundle :install @@ -548,7 +548,7 @@ end end - context "on ruby", :bundler => "2" do + context "on ruby", :bundler => "3" do before do simulate_platform("ruby") bundle :install diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index 08fe21cacfd..ca0b266041a 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -26,7 +26,7 @@ expect(out).to eq("WIN") end - it "caches the git repo", :bundler => "< 2" do + it "caches the git repo", :bundler => "< 3" do expect(Dir["#{default_bundle_path}/cache/bundler/git/foo-1.0-*"]).to have_attributes :size => 1 end diff --git a/spec/install/gemfile/groups_spec.rb b/spec/install/gemfile/groups_spec.rb index 19c379e1881..45395e606f7 100644 --- a/spec/install/gemfile/groups_spec.rb +++ b/spec/install/gemfile/groups_spec.rb @@ -192,19 +192,19 @@ expect(the_bundle).not_to include_gems "thin 1.0" end - it "does remove groups from without when passed at --with", :bundler => "< 2" do + it "does remove groups from without when passed at --with", :bundler => "< 3" do bundle :install, forgotten_command_line_options(:without => "emo") bundle :install, forgotten_command_line_options(:with => "emo") expect(the_bundle).to include_gems "activesupport 2.3.5" end - it "does remove groups from with when passed at --without", :bundler => "< 2" do + it "does remove groups from with when passed at --without", :bundler => "< 3" do bundle :install, forgotten_command_line_options(:with => "debugging") bundle :install, forgotten_command_line_options(:without => "debugging") expect(the_bundle).not_to include_gem "thin 1.0" end - it "errors out when passing a group to with and without via CLI flags", :bundler => "< 2" do + it "errors out when passing a group to with and without via CLI flags", :bundler => "< 3" do bundle :install, forgotten_command_line_options(:with => "emo debugging", :without => "emo") expect(last_command).to be_failure expect(out).to include("The offending groups are: emo") diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb index 44d1e671064..449327d3448 100644 --- a/spec/install/gemfile/path_spec.rb +++ b/spec/install/gemfile/path_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe "bundle install with explicit source paths" do - it "fetches gems with a global path source", :bundler => "< 2" do + it "fetches gems with a global path source", :bundler => "< 3" do build_lib "foo" install_gemfile <<-G diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb index bfdf9b68c8d..b5dbc41a337 100644 --- a/spec/install/gemfile/platform_spec.rb +++ b/spec/install/gemfile/platform_spec.rb @@ -230,7 +230,7 @@ expect(the_bundle).to include_gems "nokogiri 1.4.2 JAVA", "weakling 0.0.3" end - it "works with gems that have extra platform-specific runtime dependencies", :bundler => "< 2" do + it "works with gems that have extra platform-specific runtime dependencies", :bundler => "< 3" do simulate_platform x64_mac update_repo2 do diff --git a/spec/install/gemfile/sources_spec.rb b/spec/install/gemfile/sources_spec.rb index 384deca7c29..0f7c54c7979 100644 --- a/spec/install/gemfile/sources_spec.rb +++ b/spec/install/gemfile/sources_spec.rb @@ -28,7 +28,7 @@ bundle "config major_deprecations true" end - it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first", :bundler => "< 2" do + it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first", :bundler => "< 3" do bundle :install expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.") @@ -58,7 +58,7 @@ bundle "config major_deprecations true" end - it "warns about ambiguous gems, but installs anyway", :bundler => "< 2" do + it "warns about ambiguous gems, but installs anyway", :bundler => "< 3" do bundle :install expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.") @@ -248,7 +248,7 @@ G end - it "installs from the other source and warns about ambiguous gems", :bundler => "< 2" do + it "installs from the other source and warns about ambiguous gems", :bundler => "< 3" do bundle "config major_deprecations true" bundle :install expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.") @@ -276,7 +276,7 @@ G end - it "installs the dependency from the pinned source without warning", :bundler => "< 2" do + it "installs the dependency from the pinned source without warning", :bundler => "< 3" do bundle :install expect(out).not_to include("Warning: the gem 'rack' was found in multiple sources.") diff --git a/spec/install/gems/compact_index_spec.rb b/spec/install/gems/compact_index_spec.rb index 02a37a77d5e..2acade1166e 100644 --- a/spec/install/gems/compact_index_spec.rb +++ b/spec/install/gems/compact_index_spec.rb @@ -269,7 +269,7 @@ def require(*args) expect(last_command.stdboth).not_to include "Double checking" end - it "fetches again when more dependencies are found in subsequent sources", :bundler => "< 2" do + it "fetches again when more dependencies are found in subsequent sources", :bundler => "< 3" do build_repo2 do build_gem "back_deps" do |s| s.add_dependency "foo" @@ -328,7 +328,7 @@ def require(*args) expect(the_bundle).to include_gems "rack 1.2" end - it "considers all possible versions of dependencies from all api gem sources", :bundler => "< 2" do + it "considers all possible versions of dependencies from all api gem sources", :bundler => "< 3" do # In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that # exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0 # of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other @@ -352,7 +352,7 @@ def require(*args) expect(the_bundle).to include_gems "activesupport 1.2.3" end - it "considers all possible versions of dependencies from all api gem sources when using blocks", :bundler => "< 2" do + it "considers all possible versions of dependencies from all api gem sources when using blocks", :bundler => "< 3" do # In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that # exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0 # of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other @@ -458,7 +458,7 @@ def require(*args) expect(the_bundle).to include_gems "foo 1.0" end - it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 2" do + it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 3" do build_repo2 do build_gem "back_deps" do |s| s.add_dependency "foo" @@ -522,7 +522,7 @@ def require(*args) expect(the_bundle).to include_gems "rails 2.3.2" end - it "installs the binstubs", :bundler => "< 2" do + it "installs the binstubs", :bundler => "< 3" do gemfile <<-G source "#{source_uri}" gem "rack" @@ -534,7 +534,7 @@ def require(*args) expect(out).to eq("1.0.0") end - it "installs the bins when using --path and uses autoclean", :bundler => "< 2" do + it "installs the bins when using --path and uses autoclean", :bundler => "< 3" do gemfile <<-G source "#{source_uri}" gem "rack" @@ -545,7 +545,7 @@ def require(*args) expect(vendored_gems("bin/rackup")).to exist end - it "installs the bins when using --path and uses bundle clean", :bundler => "< 2" do + it "installs the bins when using --path and uses bundle clean", :bundler => "< 3" do gemfile <<-G source "#{source_uri}" gem "rack" @@ -620,7 +620,7 @@ def require(*args) expect(out).not_to include("#{user}:#{password}") end - it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 2" do + it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 3" do gemfile <<-G source "#{basic_auth_source_uri}" source "file://#{gem_repo1}" diff --git a/spec/install/gems/dependency_api_spec.rb b/spec/install/gems/dependency_api_spec.rb index 2ffe4b62d7b..3cb98db1ebd 100644 --- a/spec/install/gems/dependency_api_spec.rb +++ b/spec/install/gems/dependency_api_spec.rb @@ -243,7 +243,7 @@ def require(*args) end end - it "fetches again when more dependencies are found in subsequent sources", :bundler => "< 2" do + it "fetches again when more dependencies are found in subsequent sources", :bundler => "< 3" do build_repo2 do build_gem "back_deps" do |s| s.add_dependency "foo" @@ -302,7 +302,7 @@ def require(*args) expect(the_bundle).to include_gems "rack 1.2" end - it "considers all possible versions of dependencies from all api gem sources", :bundler => "< 2" do + it "considers all possible versions of dependencies from all api gem sources", :bundler => "< 3" do # In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that # exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0 # of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other @@ -372,7 +372,7 @@ def require(*args) expect(out).to include("Fetching source index from http://localgemserver.test/extra") end - it "does not fetch every spec if the index of gems is large when doing back deps", :bundler => "< 2" do + it "does not fetch every spec if the index of gems is large when doing back deps", :bundler => "< 3" do build_repo2 do build_gem "back_deps" do |s| s.add_dependency "foo" @@ -432,7 +432,7 @@ def require(*args) expect(the_bundle).to include_gems "foo 1.0" end - it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 2" do + it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 3" do build_repo2 do build_gem "back_deps" do |s| s.add_dependency "foo" @@ -496,7 +496,7 @@ def require(*args) expect(the_bundle).to include_gems "rails 2.3.2" end - it "installs the binstubs", :bundler => "< 2" do + it "installs the binstubs", :bundler => "< 3" do gemfile <<-G source "#{source_uri}" gem "rack" @@ -508,7 +508,7 @@ def require(*args) expect(out).to eq("1.0.0") end - it "installs the bins when using --path and uses autoclean", :bundler => "< 2" do + it "installs the bins when using --path and uses autoclean", :bundler => "< 3" do gemfile <<-G source "#{source_uri}" gem "rack" @@ -519,7 +519,7 @@ def require(*args) expect(vendored_gems("bin/rackup")).to exist end - it "installs the bins when using --path and uses bundle clean", :bundler => "< 2" do + it "installs the bins when using --path and uses bundle clean", :bundler => "< 3" do gemfile <<-G source "#{source_uri}" gem "rack" @@ -594,7 +594,7 @@ def require(*args) expect(out).not_to include("#{user}:#{password}") end - it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 2" do + it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 3" do gemfile <<-G source "#{basic_auth_source_uri}" source "file://#{gem_repo1}" diff --git a/spec/install/gems/flex_spec.rb b/spec/install/gems/flex_spec.rb index 37d2e4958a7..736f418ec70 100644 --- a/spec/install/gems/flex_spec.rb +++ b/spec/install/gems/flex_spec.rb @@ -244,7 +244,7 @@ end describe "when adding a new source" do - it "updates the lockfile", :bundler => "< 2" do + it "updates the lockfile", :bundler => "< 3" do build_repo2 install_gemfile! <<-G source "file://localhost#{gem_repo1}" @@ -274,7 +274,7 @@ L end - it "updates the lockfile", :bundler => "2" do + it "updates the lockfile", :bundler => "3" do build_repo2 install_gemfile! <<-G source "file://localhost#{gem_repo1}" diff --git a/spec/install/gems/standalone_spec.rb b/spec/install/gems/standalone_spec.rb index 10ce589eefd..fa7a3bdc277 100644 --- a/spec/install/gems/standalone_spec.rb +++ b/spec/install/gems/standalone_spec.rb @@ -197,7 +197,7 @@ expect(last_command.stderr).to eq("ZOMG LOAD ERROR") end - it "allows --path to change the location of the standalone bundle", :bundler => "< 2" do + it "allows --path to change the location of the standalone bundle", :bundler => "< 3" do bundle! "install", forgotten_command_line_options(:path => "path/to/bundle").merge(:standalone => true) Dir.chdir(bundled_app) do @@ -213,7 +213,7 @@ expect(last_command.stdout).to eq("2.3.2") end - it "allows --path to change the location of the standalone bundle", :bundler => "2" do + it "allows --path to change the location of the standalone bundle", :bundler => "3" do bundle! "install", forgotten_command_line_options(:path => "path/to/bundle").merge(:standalone => true) path = File.expand_path("path/to/bundle") @@ -273,7 +273,7 @@ end end - describe "with --binstubs", :bundler => "< 2" do + describe "with --binstubs", :bundler => "< 3" do before do gemfile <<-G source "file://#{gem_repo1}" diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb index 6ae718c2a40..48086a86c7a 100644 --- a/spec/install/git_spec.rb +++ b/spec/install/git_spec.rb @@ -2,7 +2,7 @@ RSpec.describe "bundle install" do context "git sources" do - it "displays the revision hash of the gem repository", :bundler => "< 2" do + it "displays the revision hash of the gem repository", :bundler => "< 3" do build_git "foo", "1.0", :path => lib_path("foo") install_gemfile <<-G @@ -14,7 +14,7 @@ expect(the_bundle).to include_gems "foo 1.0", :source => "git@#{lib_path("foo")}" end - it "displays the ref of the gem repository when using branch~num as a ref", :bundler => "< 2" do + it "displays the ref of the gem repository when using branch~num as a ref", :bundler => "< 3" do build_git "foo", "1.0", :path => lib_path("foo") rev = revision_for(lib_path("foo"))[0..6] update_git "foo", "2.0", :path => lib_path("foo"), :gemspec => true diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb index 44439c275e3..94f38c9290b 100644 --- a/spec/install/path_spec.rb +++ b/spec/install/path_spec.rb @@ -13,7 +13,7 @@ G end - it "does not use available system gems with bundle --path vendor/bundle", :bundler => "< 2" do + it "does not use available system gems with bundle --path vendor/bundle", :bundler => "< 3" do bundle! :install, forgotten_command_line_options(:path => "vendor/bundle") expect(the_bundle).to include_gems "rack 1.0.0" end @@ -35,13 +35,13 @@ expect(out).to include("gems are installed into `./vendor/bundle`") end - it "disallows --path vendor/bundle --system", :bundler => "< 2" do + it "disallows --path vendor/bundle --system", :bundler => "< 3" do bundle "install --path vendor/bundle --system" expect(out).to include("Please choose only one option.") expect(exitstatus).to eq(15) if exitstatus end - it "remembers to disable system gems after the first time with bundle --path vendor/bundle", :bundler => "< 2" do + it "remembers to disable system gems after the first time with bundle --path vendor/bundle", :bundler => "< 3" do bundle "install --path vendor/bundle" FileUtils.rm_rf bundled_app("vendor") bundle "install" @@ -53,7 +53,7 @@ context "with path_relative_to_cwd set to true" do before { bundle! "config path_relative_to_cwd true" } - it "installs the bundle relatively to current working directory", :bundler => "< 2" do + it "installs the bundle relatively to current working directory", :bundler => "< 3" do Dir.chdir(bundled_app.parent) do bundle! "install --gemfile='#{bundled_app}/Gemfile' --path vendor/bundle" expect(out).to include("installed into `./vendor/bundle`") @@ -113,7 +113,7 @@ def set_bundle_path(type, location) expect(the_bundle).to include_gems "rack 1.0.0" end - context "with global_path_appends_ruby_scope set", :bundler => "2" do + context "with global_path_appends_ruby_scope set", :bundler => "3" do it "installs gems to ." do set_bundle_path(type, ".") bundle! "config --global disable_shared_gems true" @@ -147,7 +147,7 @@ def set_bundle_path(type, location) end end - context "with global_path_appends_ruby_scope unset", :bundler => "< 2" do + context "with global_path_appends_ruby_scope unset", :bundler => "< 3" do it "installs gems to ." do set_bundle_path(type, ".") bundle! "config --global disable_shared_gems true" diff --git a/spec/install/post_bundle_message_spec.rb b/spec/install/post_bundle_message_spec.rb index eadc8a4d854..394134f5230 100644 --- a/spec/install/post_bundle_message_spec.rb +++ b/spec/install/post_bundle_message_spec.rb @@ -19,7 +19,7 @@ let(:bundle_complete_message) { "Bundle complete!" } let(:bundle_updated_message) { "Bundle updated!" } let(:installed_gems_stats) { "4 Gemfile dependencies, 5 gems now installed." } - let(:bundle_show_message) { Bundler::VERSION.split(".").first.to_i < 2 ? bundle_show_system_message : bundle_show_path_message } + let(:bundle_show_message) { Bundler::VERSION.split(".").first.to_i < 3 ? bundle_show_system_message : bundle_show_path_message } describe "for fresh bundle install" do it "without any options" do @@ -101,7 +101,7 @@ end describe "with misspelled or non-existent gem name" do - it "should report a helpful error message", :bundler => "< 2" do + it "should report a helpful error message", :bundler => "< 3" do install_gemfile <<-G source "file://localhost#{gem_repo1}" gem "rack" @@ -110,7 +110,7 @@ expect(out).to include("Could not find gem 'not-a-gem' in any of the gem sources listed in your Gemfile.") end - it "should report a helpful error message", :bundler => "2" do + it "should report a helpful error message", :bundler => "3" do install_gemfile <<-G source "file://localhost#{gem_repo1}" gem "rack" diff --git a/spec/install/process_lock_spec.rb b/spec/install/process_lock_spec.rb index be8fd04fddb..df1e9c63505 100644 --- a/spec/install/process_lock_spec.rb +++ b/spec/install/process_lock_spec.rb @@ -21,7 +21,7 @@ expect(the_bundle).to include_gems "rack 1.0" end - context "when creating a lock raises Errno::ENOTSUP", :ruby => ">= 1.9" do + context "when creating a lock raises Errno::ENOTSUP" do before { allow(File).to receive(:open).and_raise(Errno::ENOTSUP) } it "skips creating the lock file and yields" do diff --git a/spec/install/redownload_spec.rb b/spec/install/redownload_spec.rb index 232c0f9e2cc..ea93ad3946a 100644 --- a/spec/install/redownload_spec.rb +++ b/spec/install/redownload_spec.rb @@ -61,24 +61,24 @@ let(:flag) { "force" } end - it "shows a deprecation when single flag passed", :bundler => 2 do + it "shows a deprecation when single flag passed", :bundler => 3 do bundle! "install --force" - expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end - it "shows a deprecation when multiple flags passed", :bundler => 2 do + it "shows a deprecation when multiple flags passed", :bundler => 3 do bundle! "install --no-color --force" - expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end - it "does not show a deprecation when single flag passed", :bundler => "< 2" do + it "does not show a deprecation when single flag passed", :bundler => "< 3" do bundle! "install --force" - expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).not_to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end - it "does not show a deprecation when multiple flags passed", :bundler => "< 2" do + it "does not show a deprecation when multiple flags passed", :bundler => "< 3" do bundle! "install --no-color --force" - expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).not_to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end end @@ -89,12 +89,12 @@ it "does not show a deprecation when single flag passed" do bundle! "install --redownload" - expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).not_to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end it "does not show a deprecation when single multiple flags passed" do bundle! "install --no-color --redownload" - expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).not_to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end end end diff --git a/spec/lock/lockfile_bundler_1_spec.rb b/spec/lock/lockfile_bundler_1_spec.rb index 638b40f5f48..e89c5078d93 100644 --- a/spec/lock/lockfile_bundler_1_spec.rb +++ b/spec/lock/lockfile_bundler_1_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "the lockfile format", :bundler => "< 2" do +RSpec.describe "the lockfile format", :bundler => "< 3" do include Bundler::GemHelpers before { ENV["BUNDLER_SPEC_IGNORE_COMPATIBILITY_GUARD"] = "TRUE" } diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb index 53c832445fd..9e2fb3b2dd0 100644 --- a/spec/lock/lockfile_spec.rb +++ b/spec/lock/lockfile_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "the lockfile format", :bundler => "2" do +RSpec.describe "the lockfile format", :bundler => "3" do include Bundler::GemHelpers before { ENV["BUNDLER_SPEC_IGNORE_COMPATIBILITY_GUARD"] = "TRUE" } @@ -428,7 +428,7 @@ expect(the_bundle).to include_gems "net-sftp 1.1.1", "net-ssh 1.0.0" end - it "generates a simple lockfile for a single pinned source, gem with a version requirement", :bundler => "< 2" do + it "generates a simple lockfile for a single pinned source, gem with a version requirement", :bundler => "< 3" do git = build_git "foo" install_gemfile <<-G diff --git a/spec/other/bundle_ruby_spec.rb b/spec/other/bundle_ruby_spec.rb index a7da9cbec9d..fbca31d0a04 100644 --- a/spec/other/bundle_ruby_spec.rb +++ b/spec/other/bundle_ruby_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "bundle_ruby", :bundler => "< 2" do +RSpec.describe "bundle_ruby", :bundler => "< 3" do context "without patchlevel" do it "returns the ruby version" do gemfile <<-G diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb index ce2735ba94a..e1ceb2ede5f 100644 --- a/spec/other/major_deprecation_spec.rb +++ b/spec/other/major_deprecation_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "major deprecations", :bundler => "< 2" do +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)? >= .*/, "") } @@ -202,25 +202,25 @@ 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: +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 - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg) 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 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: +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 - 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") + 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) @@ -231,7 +231,7 @@ 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: +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: git_source(:bitbucket) do |repo_name| user_name, repo_name = repo_name.split("/") @@ -240,7 +240,7 @@ end EOS - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg) subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails") end end @@ -249,10 +249,10 @@ 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 " \ + "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" - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg) subject.gem("not-really-a-gem", :gist => "1234") end end diff --git a/spec/other/platform_spec.rb b/spec/other/platform_spec.rb index ca749455635..6c59fd893c4 100644 --- a/spec/other/platform_spec.rb +++ b/spec/other/platform_spec.rb @@ -4,7 +4,7 @@ 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.unshift(specific_local_platform) if Bundler.feature_flag.bundler_3_mode? platforms.map {|pl| "* #{pl}" }.join("\n") end @@ -633,7 +633,7 @@ def should_be_patchlevel_fixnum end end - it "fails if ruby version doesn't match", :bundler => "< 2" do + it "fails if ruby version doesn't match", :bundler => "< 3" do gemfile <<-G source "file://#{gem_repo1}" gem "rails" @@ -645,7 +645,7 @@ def should_be_patchlevel_fixnum should_be_ruby_version_incorrect end - it "fails if engine doesn't match", :bundler => "< 2" do + it "fails if engine doesn't match", :bundler => "< 3" do gemfile <<-G source "file://#{gem_repo1}" gem "rails" @@ -657,7 +657,7 @@ def should_be_patchlevel_fixnum should_be_engine_incorrect end - it "fails if engine version doesn't match", :bundler => "< 2" do + it "fails if engine version doesn't match", :bundler => "< 3" do simulate_ruby_engine "jruby" do gemfile <<-G source "file://#{gem_repo1}" @@ -671,7 +671,7 @@ def should_be_patchlevel_fixnum end end - it "fails when patchlevel doesn't match", :bundler => "< 2" do + it "fails when patchlevel doesn't match", :bundler => "< 3" do gemfile <<-G source "file://#{gem_repo1}" gem "rack" @@ -928,7 +928,7 @@ def should_be_patchlevel_fixnum end end - context "bundle console", :bundler => "< 2" do + context "bundle console", :bundler => "< 3" do before do install_gemfile <<-G source "file://#{gem_repo1}" diff --git a/spec/plugins/source/example_spec.rb b/spec/plugins/source/example_spec.rb index fd30892f635..d9a3cd2b92f 100644 --- a/spec/plugins/source/example_spec.rb +++ b/spec/plugins/source/example_spec.rb @@ -67,7 +67,7 @@ def install(spec, opts) expect(the_bundle).to include_gems("a-path-gem 1.0") end - it "writes to lock file", :bundler => "< 2" do + it "writes to lock file", :bundler => "< 3" do bundle "install" lockfile_should_be <<-G @@ -92,7 +92,7 @@ def install(spec, opts) G end - it "writes to lock file", :bundler => "2" do + it "writes to lock file", :bundler => "3" do bundle "install" lockfile_should_be <<-G @@ -359,7 +359,7 @@ def installed? expect(the_bundle).to include_gems("ma-gitp-gem 1.0") end - it "writes to lock file", :bundler => "< 2" do + it "writes to lock file", :bundler => "< 3" do revision = revision_for(lib_path("ma-gitp-gem-1.0")) bundle "install" @@ -386,7 +386,7 @@ def installed? G end - it "writes to lock file", :bundler => "2" do + it "writes to lock file", :bundler => "3" do revision = revision_for(lib_path("ma-gitp-gem-1.0")) bundle "install" diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index 64590befdf3..34b7745dc37 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -181,6 +181,7 @@ def check_for_specific_pronouns(filename) gem.coc gem.mit inline + lockfile_upgrade_warning lockfile_uses_separate_rubygems_sources use_gem_version_promoter_for_major_updates viz_command diff --git a/spec/realworld/double_check_spec.rb b/spec/realworld/double_check_spec.rb index 94ab49ba2a6..6fee578a71a 100644 --- a/spec/realworld/double_check_spec.rb +++ b/spec/realworld/double_check_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe "double checking sources", :realworld => true do - it "finds already-installed gems", :ruby => ">= 2.2" do + it "finds already-installed gems" do create_file("rails.gemspec", <<-RUBY) Gem::Specification.new do |s| s.name = "rails" diff --git a/spec/realworld/edgecases_spec.rb b/spec/realworld/edgecases_spec.rb index aa60e20b8a2..80fcd271784 100644 --- a/spec/realworld/edgecases_spec.rb +++ b/spec/realworld/edgecases_spec.rb @@ -57,7 +57,7 @@ def rubygems_version(name, requirement) expect(lockfile).to include("activemodel (3.0.5)") end - it "resolves dependencies correctly", :ruby => "1.9.3" do + it "resolves dependencies correctly", :ruby => "<= 1.9.3" do gemfile <<-G source "https://rubygems.org" @@ -70,7 +70,7 @@ def rubygems_version(name, requirement) expect(lockfile).to include("capybara (2.2.1)") end - it "installs the latest version of gxapi_rails", :ruby => "1.9.3" do + it "installs the latest version of gxapi_rails", :ruby => "<= 1.9.3" do gemfile <<-G source "https://rubygems.org" @@ -97,7 +97,7 @@ def rubygems_version(name, requirement) expect(lockfile).to include(rubygems_version("activesupport", "~> 3.0")) end - it "is able to update a top-level dependency when there is a conflict on a shared transitive child", :ruby => "2.1" do + it "is able to update a top-level dependency when there is a conflict on a shared transitive child" do # from https://github.com/bundler/bundler/issues/5031 gemfile <<-G @@ -188,7 +188,7 @@ def rubygems_version(name, requirement) activemodel (= 4.2.7.1) activerecord (= 4.2.7.1) activesupport (= 4.2.7.1) - bundler (>= 1.3.0, < 2.0) + bundler (>= 1.3.0, < 3.0) railties (= 4.2.7.1) sprockets-rails rails-deprecated_sanitizer (1.0.3) diff --git a/spec/runtime/executable_spec.rb b/spec/runtime/executable_spec.rb index dcee234e152..7eed500d193 100644 --- a/spec/runtime/executable_spec.rb +++ b/spec/runtime/executable_spec.rb @@ -99,7 +99,7 @@ expect(bundled_app("bin/rackup")).not_to exist end - it "allows you to stop installing binstubs", :bundler => "< 2" do + it "allows you to stop installing binstubs", :bundler => "< 3" do bundle! "install --binstubs bin/" bundled_app("bin/rackup").rmtree bundle! "install --binstubs \"\"" @@ -110,7 +110,7 @@ expect(out).to include("You have not configured a value for `bin`") end - it "remembers that the option was specified", :bundler => "< 2" do + it "remembers that the option was specified", :bundler => "< 3" do gemfile <<-G source "file://#{gem_repo1}" gem "activesupport" @@ -129,7 +129,7 @@ expect(bundled_app("bin/rackup")).to exist end - it "rewrites bins on --binstubs (to maintain backwards compatibility)", :bundler => "< 2" do + it "rewrites bins on --binstubs (to maintain backwards compatibility)", :bundler => "< 3" do gemfile <<-G source "file://#{gem_repo1}" gem "rack" diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 941c3d34e7f..54a586a8ef5 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -1383,7 +1383,7 @@ def lock_with(ruby_version = nil) end describe "after setup" do - it "allows calling #gem on random objects", :bundler => "< 2" do + it "allows calling #gem on random objects", :bundler => "< 3" do install_gemfile <<-G source "file:#{gem_repo1}" gem "rack" @@ -1398,7 +1398,7 @@ def lock_with(ruby_version = nil) expect(out).to eq("rack-1.0.0") end - it "keeps Kernel#gem private", :bundler => "2" do + it "keeps Kernel#gem private", :bundler => "3" do install_gemfile! <<-G source "file:#{gem_repo1}" gem "rack" diff --git a/spec/runtime/with_unbundled_env_spec.rb b/spec/runtime/with_unbundled_env_spec.rb index 83eb1eac130..c7ee0d33087 100644 --- a/spec/runtime/with_unbundled_env_spec.rb +++ b/spec/runtime/with_unbundled_env_spec.rb @@ -107,20 +107,20 @@ def build_bundler_context it_behaves_like "an unbundling helper" - it "prints a deprecation", :bundler => 2 do + it "prints a deprecation", :bundler => 3 do code = "Bundler.clean_env" bundle_exec_ruby! code.dump expect(last_command.stdboth).to include( - "[DEPRECATED FOR 2.0] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \ + "[DEPRECATED FOR 3.0] `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 - it "does not print a deprecation", :bundler => "< 2" do + it "does not print a deprecation", :bundler => "< 3" do code = "Bundler.clean_env" bundle_exec_ruby! code.dump expect(last_command.stdboth).not_to include( - "[DEPRECATED FOR 2.0] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \ + "[DEPRECATED FOR 3.0] `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 @@ -157,20 +157,20 @@ def build_bundler_context expect(ENV).not_to have_key("FOO") end - it "prints a deprecation", :bundler => 2 do + it "prints a deprecation", :bundler => 3 do code = "Bundler.with_clean_env {}" bundle_exec_ruby! code.dump expect(last_command.stdboth).to include( - "[DEPRECATED FOR 2.0] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \ + "[DEPRECATED FOR 3.0] `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 - it "does not print a deprecation", :bundler => "< 2" do + it "does not print a deprecation", :bundler => "< 3" do code = "Bundler.with_clean_env {}" bundle_exec_ruby! code.dump expect(last_command.stdboth).not_to include( - "[DEPRECATED FOR 2.0] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \ + "[DEPRECATED FOR 3.0] `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 @@ -192,14 +192,14 @@ def build_bundler_context end end - describe "Bundler.clean_system", :ruby => ">= 1.9", :bundler => "< 2" do + describe "Bundler.clean_system" do it "runs system inside with_clean_env" do Bundler.clean_system(%(echo 'if [ "$BUNDLE_PATH" = "" ]; then exit 42; else exit 1; fi' | /bin/sh)) expect($?.exitstatus).to eq(42) end end - describe "Bundler.clean_exec", :ruby => ">= 1.9", :bundler => "< 2" do + describe "Bundler.clean_exec" do it "runs exec inside with_clean_env" do pid = Kernel.fork do Bundler.clean_exec(%(echo 'if [ "$BUNDLE_PATH" = "" ]; then exit 42; else exit 1; fi' | /bin/sh)) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9355bfb33f4..51c74f1b688 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -28,6 +28,18 @@ module Gem require "uri" require "digest" +# Delete the default copy of Bundler that RVM installs for us when running in CI +require "fileutils" +if ENV.select {|k, _v| k =~ /TRAVIS/ }.any? && Gem::Version.new(Gem::VERSION) > Gem::Version.new("2.0") + Dir.glob(File.join(Gem::Specification.default_specifications_dir, "bundler*.gemspec")).each do |file| + FileUtils.rm_rf(file) + end + + Dir.glob(File.join(RbConfig::CONFIG["sitelibdir"], "bundler*")).each do |file| + FileUtils.rm_rf(file) + end +end + if File.expand_path(__FILE__) =~ %r{([^\w/\.:\-])} abort "The bundler specs cannot be run from a path that contains special characters (particularly #{$1.inspect})" end diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 9126256f8e9..97b3d11087b 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -53,7 +53,7 @@ def exitstatus end def bundle_update_requires_all? - Bundler::VERSION.start_with?("1.") ? nil : true + Bundler::VERSION.start_with?("2.") ? nil : true end def in_app_root(&blk) @@ -152,7 +152,7 @@ def bundle(cmd, options = {}) bang :bundle def forgotten_command_line_options(options) - remembered = Bundler::VERSION.split(".", 2).first == "1" + remembered = Bundler.bundler_major_version < 3 options = options.map do |k, v| k = Array(k)[remembered ? 0 : -1] v = '""' if v && v.to_s.empty? diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index 8e17be3a024..013fd699a63 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -60,7 +60,7 @@ def self.define_compound_matcher(matcher, preconditions, &declarations) end end - MAJOR_DEPRECATION = /^\[DEPRECATED FOR 2\.0\]\s*/ + MAJOR_DEPRECATION = /^\[DEPRECATED FOR 3\.0\]\s*/ RSpec::Matchers.define :lack_errors do diffable diff --git a/spec/support/path.rb b/spec/support/path.rb index f85fbf330f2..33433c09190 100644 --- a/spec/support/path.rb +++ b/spec/support/path.rb @@ -29,7 +29,7 @@ def home(*path) end def default_bundle_path(*path) - if Bundler::VERSION.split(".").first.to_i < 2 + if Bundler::VERSION.split(".").first.to_i < 3 system_gem_path(*path) else bundled_app(*[".bundle", ENV.fetch("BUNDLER_SPEC_RUBY_ENGINE", Gem.ruby_engine), Gem::ConfigMap[:ruby_version], *path].compact) diff --git a/spec/support/platforms.rb b/spec/support/platforms.rb index 39040a61bd5..950311d20e4 100644 --- a/spec/support/platforms.rb +++ b/spec/support/platforms.rb @@ -106,7 +106,7 @@ def lockfile_platforms(*platforms) end def local_platforms - if Bundler::VERSION.split(".").first.to_i > 1 + if Bundler::VERSION.split(".").first.to_i > 2 [local, specific_local_platform] else [local] diff --git a/spec/update/git_spec.rb b/spec/update/git_spec.rb index b4cbb794342..d97760e84b5 100644 --- a/spec/update/git_spec.rb +++ b/spec/update/git_spec.rb @@ -299,7 +299,7 @@ G end - it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "< 2" do + it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "> 3" do spec_lines = lib_path("bar/foo.gemspec").read.split("\n") spec_lines[5] = "s.version = '2.0'" @@ -335,7 +335,7 @@ G end - it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "2" do + it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "3" do spec_lines = lib_path("bar/foo.gemspec").read.split("\n") spec_lines[5] = "s.version = '2.0'" diff --git a/spec/update/redownload_spec.rb b/spec/update/redownload_spec.rb index 5a739c51b3e..fd75ce2368a 100644 --- a/spec/update/redownload_spec.rb +++ b/spec/update/redownload_spec.rb @@ -9,36 +9,36 @@ end describe "with --force" do - it "shows a deprecation when single flag passed", :bundler => 2 do + it "shows a deprecation when single flag passed", :bundler => 3 do bundle! "update rack --force" - expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end - it "shows a deprecation when multiple flags passed", :bundler => 2 do + it "shows a deprecation when multiple flags passed", :bundler => 3 do bundle! "update rack --no-color --force" - expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end - it "does not show a deprecation when single flag passed", :bundler => "< 2" do + it "does not show a deprecation when single flag passed", :bundler => "< 3" do bundle! "update rack --force" - expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).not_to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end - it "does not show a deprecation when multiple flags passed", :bundler => "< 2" do + it "does not show a deprecation when multiple flags passed", :bundler => "< 3" do bundle! "update rack --no-color --force" - expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).not_to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end end describe "with --redownload" do it "does not show a deprecation when single flag passed" do bundle! "update rack --redownload" - expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).not_to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end it "does not show a deprecation when single multiple flags passed" do bundle! "update rack --no-color --redownload" - expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).not_to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end end end