diff options
author | Homu <homu@barosl.com> | 2016-07-13 08:36:33 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-07-13 08:36:33 +0900 |
commit | ce40e1f365d9ea69d6e9e0290c4ddfd57a59d934 (patch) | |
tree | cd326c443dd9036b9b07c9e43e8ae289cae1a0c2 | |
parent | d794552dd915da6e3b503da0fe20cb2d49b2578f (diff) | |
parent | f94755cb4b0524c6225b31b133c5c93193f3a523 (diff) | |
download | bundler-ce40e1f365d9ea69d6e9e0290c4ddfd57a59d934.tar.gz |
Auto merge of #4741 - bundler:seg-1-99-rebase, r=indirect
Re-integrate 1-99-dev into master
@indirect please make sure I didn't miss anything here?
41 files changed, 440 insertions, 152 deletions
diff --git a/.rubocop.yml b/.rubocop.yml index 8ad27fbe1f..cbce695fbd 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -118,3 +118,8 @@ Metrics/AbcSize: Metrics/CyclomaticComplexity: Enabled: false + +# It will be obvious which code is complex, Rubocop should only lint simple +# rules for us. +Metrics/PerceivedComplexity: + Enabled: false diff --git a/.travis.yml b/.travis.yml index e6ed6d595c..f1aeb66244 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ branches: only: - master - auto + - /.+-dev$/ - /.+-stable$/ notifications: diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index d6afd275e5..ed81ffbf35 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -31,6 +31,7 @@ module Bundler raise InvalidOption, e.message ensure self.options ||= {} + Bundler.settings.cli_flags_given = !options.empty? Bundler.ui = UI::Shell.new(options) Bundler.ui.level = "debug" if options["verbose"] @@ -231,9 +232,11 @@ module Bundler method_option "outdated", :type => :boolean, :banner => "Show verbose output including whether gems are outdated." def show(gem_name = nil) + Bundler::SharedHelpers.major_deprecation("use `bundle show` instead of `bundle list`") if ARGV[0] == "list" require "bundler/cli/show" Show.new(options, gem_name).run end + # TODO: 2.0 remove `bundle list` map %w(list) => "show" desc "binstubs GEM [OPTIONS]", "Install the binstubs of the listed gem" @@ -348,6 +351,7 @@ module Bundler desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded" def console(group = nil) + # TODO: Remove for 2.0 require "bundler/cli/console" Console.new(options, group).run end diff --git a/lib/bundler/cli/console.rb b/lib/bundler/cli/console.rb index 5e72cdbf0f..715abf2554 100644 --- a/lib/bundler/cli/console.rb +++ b/lib/bundler/cli/console.rb @@ -8,6 +8,9 @@ module Bundler end def run + Bundler::SharedHelpers.major_deprecation "bundle console will be replaced " \ + "by `bin/console` generated by `bundle gem <name>`" + group ? Bundler.require(:default, *(group.split.map!(&:to_sym))) : Bundler.require ARGV.clear diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index 07950c9010..2dee4a5a77 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -55,6 +55,11 @@ module Bundler Bundler::Fetcher.disable_endpoint = options["full-index"] + if options["binstubs"] + Bundler::SharedHelpers.major_deprecation \ + "the --binstubs option will be removed in favor of `bundle binstubs`" + end + # rubygems plugins sometimes hook into the gem install process Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins) diff --git a/lib/bundler/deployment.rb b/lib/bundler/deployment.rb index 23968e7084..94f2fac620 100644 --- a/lib/bundler/deployment.rb +++ b/lib/bundler/deployment.rb @@ -1,4 +1,10 @@ # frozen_string_literal: true + +require "bundler/shared_helpers" +Bundler::SharedHelpers.major_deprecation "Bundler no longer integrates with " \ + "Capistrano, but Capistrano provides its own integration with " \ + "Bundler via the capistrano-bundler gem. Use it instead." + module Bundler class Deployment def self.define_task(context, task_method = :task, opts = {}) diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 04ef641b8e..0436b58f3a 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -265,13 +265,25 @@ module Bundler # "https://github.com/#{repo_name}.git" # end repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") - "git://github.com/#{repo_name}.git" + # TODO: 2.0 upgrade this setting to the default + if Bundler.settings["github.https"] + "https://github.com/#{repo_name}.git" + else + warn_github_source_change(repo_name) + "git://github.com/#{repo_name}.git" + end end - git_source(:gist) {|repo_name| "https://gist.github.com/#{repo_name}.git" } + # TODO: 2.0 remove this deprecated git source + git_source(:gist) do |repo_name| + warn_deprecated_git_source(:gist, 'https://gist.github.com/#{repo_name}.git') + "https://gist.github.com/#{repo_name}.git" + end + # TODO: 2.0 remove this deprecated git source git_source(:bitbucket) do |repo_name| user_name, repo_name = repo_name.split "/" + warn_deprecated_git_source(:bitbucket, 'https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git') repo_name ||= user_name "https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git" end @@ -403,13 +415,14 @@ module Bundler def check_primary_source_safety(source) return unless source.rubygems_primary_remotes.any? + # TODO: 2.0 upgrade from setting to default if Bundler.settings[:disable_multisource] raise GemspecError, "Warning: this Gemfile contains multiple primary sources. " \ "Each source after the first must include a block to indicate which gems " \ "should come from that source. To downgrade this error to a warning, run " \ "`bundle config --delete disable_multisource`" else - Bundler.ui.warn "Warning: this Gemfile contains multiple primary sources. " \ + Bundler::SharedHelpers.major_deprecation "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. " \ @@ -418,6 +431,23 @@ module Bundler end end + def warn_github_source_change(repo_name) + # TODO: 2.0 remove deprecation + Bundler::SharedHelpers.major_deprecation "The :github option uses the git: protocol, which is not secure. " \ + "Bundler 2.0 will use the https: protocol, which is secure. Enable this change now by " \ + "running `bundle config github.https true`." + end + + def warn_deprecated_git_source(name, repo_string) + # TODO: 2.0 remove deprecation + Bundler::SharedHelpers.major_deprecation <<-EOS +The :#{name} git source is deprecated, and will be removed in Bundler 2.0. Add this code to your Gemfile to ensure it continues to work: + git_source(:#{name}) do |repo_name| + "#{repo_string}" + end + EOS + end + class DSLError < GemfileError # @return [String] the description that should be presented to the user. # diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 46333c8986..ff0b146054 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -31,10 +31,13 @@ module Bundler :timeout => 10, }.freeze + attr_accessor :cli_flags_given + def initialize(root = nil) - @root = root - @local_config = load_config(local_config_file) - @global_config = load_config(global_config_file) + @root = root + @local_config = load_config(local_config_file) + @global_config = load_config(global_config_file) + @cli_flags_given = false end def [](name) @@ -54,6 +57,19 @@ module Bundler end def []=(key, value) + if cli_flags_given + command = if value.nil? + "bundle config --delete #{key}" + else + "bundle config #{key} #{Array(value).join(":")}" + end + + Bundler::SharedHelpers.major_deprecation \ + "flags passed to commands " \ + "will no longer be automatically remembered. Instead please set flags " \ + "you want remembered between commands using `bundle config " \ + "<setting name> <setting value>`, i.e. `#{command}`" + end local_config_file || raise(GemfileNotFound, "Could not locate Gemfile") set_key(key, value, @local_config, local_config_file) end diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index df0fffbaed..efbedeb374 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -128,6 +128,7 @@ module Bundler end def print_major_deprecations! + deprecate_gemfile(find_gemfile) if find_gemfile == find_file("Gemfile") if RUBY_VERSION < "2" major_deprecation("Bundler will only support ruby >= 2.0, you are running #{RUBY_VERSION}") end @@ -140,7 +141,6 @@ module Bundler def find_gemfile given = ENV["BUNDLE_GEMFILE"] return given if given && !given.empty? - find_file("Gemfile", "gems.rb") end @@ -230,6 +230,12 @@ module Bundler true end + def deprecate_gemfile(gemfile) + return unless gemfile && File.basename(gemfile) == "Gemfile" + Bundler::SharedHelpers.major_deprecation \ + "gems.rb and gems.locked will be prefered to Gemfile and Gemfile.lock." + end + extend self end end diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb index fdc77cb23d..b6ce6029c8 100644 --- a/lib/bundler/source_list.rb +++ b/lib/bundler/source_list.rb @@ -22,7 +22,9 @@ module Bundler end def add_git_source(options = {}) - add_source_to_list Source::Git.new(options), git_sources + add_source_to_list(Source::Git.new(options), git_sources).tap do |source| + warn_on_git_protocol(source) + end end def add_rubygems_source(options = {}) @@ -109,5 +111,16 @@ module Bundler def combine_rubygems_sources Source::Rubygems.new("remotes" => rubygems_remotes) end + + def warn_on_git_protocol(source) + return if Bundler.settings["git.allow_insecure"] + + if source.uri =~ /^git\:/ + Bundler.ui.warn "The git source `#{source.uri}` uses the `git` protocol, " \ + "which transmits data without encryption. Disable this warning with " \ + "`bundle config git.allow_insecure true`, or switch to the `https` " \ + "protocol to keep your data secure." + end + end end end diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb index df41d72768..195bd56a5c 100644 --- a/lib/bundler/ui/shell.rb +++ b/lib/bundler/ui/shell.rb @@ -95,6 +95,14 @@ module Bundler end end + def tell_err(message, color = nil, newline = nil) + buffer = @shell.send(:prepare_message, message, *color) + buffer << "\n" if newline && !message.to_s.end_with?("\n") + + @shell.send(:stderr).print(buffer) + @shell.send(:stderr).flush + end + def strip_leading_spaces(text) spaces = text[/\A\s+/, 0] spaces ? text.gsub(/#{spaces}/, "") : text diff --git a/lib/bundler/ui/silent.rb b/lib/bundler/ui/silent.rb index 19ff7311c0..367eaa58c2 100644 --- a/lib/bundler/ui/silent.rb +++ b/lib/bundler/ui/silent.rb @@ -41,9 +41,6 @@ module Bundler def trace(message, newline = nil) end - def major_deprecation(message) - end - def silence yield end diff --git a/man/bundle-config.ronn b/man/bundle-config.ronn index d617ae340b..3ea6d10973 100644 --- a/man/bundle-config.ronn +++ b/man/bundle-config.ronn @@ -39,6 +39,38 @@ Executing `bundle config disable_multisource true` upgrades the warning about the Gemfile containing multiple primary sources to an error. Executing `bundle config --delete disable_multisource` downgrades this error to a warning. +## REMEMBERING OPTIONS + +Flags passed to `bundle install` or the Bundler runtime, +such as `--path foo` or `--without production`, are not remembered between commands. +If these options must be remembered,they must be set using `bundle config` +(e.g., `bundle config path foo`). + +The options that can be configured are: + +* `binstubs`: + Creates a directory (defaults to `~/bin`) and place any executables from the + gem there. These executables run in Bundler's context. If used, you might add + this directory to your environment's `PATH` variable. For instance, if the + `rails` gem comes with a `rails` executable, this flag will create a + `bin/rails` executable that ensures that all referred dependencies will be + resolved using the bundled gems. + +* `deployment`: + In deployment mode, Bundler will 'roll-out' the bundle for + `production` use. Please check carefully if you want to have this option + enabled in `development` or `test` environments. + +* `path`: + The location to install the specified gems to. This defaults to Rubygems' + setting. Bundler shares this location with Rubygems, `gem install ...` will + have gem installed there, too. Therefore, gems installed without a + `--path ...` setting will show up by calling `gem list`. Accodingly, gems + installed to other locations will not get listed. + +* `without`: + A space-separated list of groups referencing gems to skip during installation. + ## BUILD OPTIONS You can use `bundle config` to give bundler the flags to pass to the gem diff --git a/man/bundle-install.ronn b/man/bundle-install.ronn index b5391fa024..92d1d8d42c 100644 --- a/man/bundle-install.ronn +++ b/man/bundle-install.ronn @@ -43,6 +43,9 @@ update process below under [CONSERVATIVE UPDATING][]. ## OPTIONS +To apply any of `--deployment`, `--path`, `--binstubs`, or `--without` every +time `bundle install` is run, use `bundle config` (see bundle-config(1)). + * `--binstubs[=<directory>]`: Creates a directory (defaults to `~/bin`) and place any executables from the gem there. These executables run in Bundler's context. If used, you might add @@ -93,7 +96,7 @@ update process below under [CONSERVATIVE UPDATING][]. * `--system`: Installs the gems specified in the bundle to the system's Rubygems location. - This overrides any previous [remembered][REMEMBERED OPTIONS] use of `--path`. + This overrides any previous configuration of `--path`. * `--no-cache`: Do not update the cache in `vendor/cache` with the newly bundled gems. This @@ -108,8 +111,7 @@ update process below under [CONSERVATIVE UPDATING][]. setting. Bundler shares this location with Rubygems, `gem install ...` will have gem installed there, too. Therefore, gems installed without a `--path ...` setting will show up by calling `gem list`. Accodingly, gems - installed to other locations will not get listed. This setting is a - [remembered option][REMEMBERED OPTIONS]. + installed to other locations will not get listed. * `--quiet`: Do not print progress information to the standard output. Instead, Bundler @@ -142,14 +144,12 @@ update process below under [CONSERVATIVE UPDATING][]. A space-separated list of groups referencing gems to skip during installation. If a group is given that is in the remembered list of groups given to --with, it is removed from that list. - This is a [remembered option][REMEMBERED OPTIONS]. * `--with=<list>`: A space-separated list of groups referencing gems to install. If an optional group is given it is installed. If a group is given that is in the remembered list of groups given to --without, it is removed - from that list. This is a [remembered option][REMEMBERED OPTIONS]. - + from that list. ## DEPLOYMENT MODE @@ -274,41 +274,6 @@ the vagaries of the dependency resolution process, this usually affects more than the gems you list in your Gemfile(5), and can (surprisingly) radically change the gems you are using. -## REMEMBERED OPTIONS - -Some options (marked above in the [OPTIONS][] section) are remembered -between calls to `bundle install`, and by the Bundler runtime. - -For instance, if you run `bundle install --without test`, a subsequent -call to `bundle install` that does not include a `--without` flag will -remember your previous choice. - -In addition, a call to `Bundler.setup` will not attempt to make the -gems in those groups available on the Ruby load path, as they were -not installed. - -The settings that are remembered are: - -* `--deployment`: - At runtime, this remembered setting will also result in Bundler - raising an exception if the `Gemfile.lock` is out of date. - -* `--path`: - Subsequent calls to `bundle install` will install gems to the - directory originally passed to `--path`. The Bundler runtime - will look for gems in that location. You can revert this - option by running `bundle install --system`. - -* `--binstubs`: - Bundler will update the executables every subsequent call to - `bundle install`. - -* `--without`: - As described above, Bundler will skip the gems specified by - `--without` in subsequent calls to `bundle install`. The - Bundler runtime will also not try to make the gems in the - skipped groups available. - ## THE GEMFILE.LOCK When you run `bundle install`, Bundler will persist the full names diff --git a/man/bundle.ronn b/man/bundle.ronn index bd01276ff0..55e2c4afe8 100644 --- a/man/bundle.ronn +++ b/man/bundle.ronn @@ -52,9 +52,6 @@ We divide `bundle` subcommands into primary commands and utilities. Determine whether the requirements for your application are installed and available to bundler -* `bundle list(1)`: - Show all of the gems in the current bundle - * `bundle show(1)`: Show the source location of a particular gem in the bundle @@ -96,3 +93,4 @@ and execute it, passing down any extra arguments to it. These commands are obsolete and should no longer be used * `bundle cache(1)` +* `bundle list(1)` diff --git a/spec/bundler/source_list_spec.rb b/spec/bundler/source_list_spec.rb index 56f17f9af9..3657ac0927 100644 --- a/spec/bundler/source_list_spec.rb +++ b/spec/bundler/source_list_spec.rb @@ -3,7 +3,7 @@ require "spec_helper" describe Bundler::SourceList do before do - allow(Bundler).to receive(:root) { Pathname.new "/" } + allow(Bundler).to receive(:root) { Pathname.new "./tmp/bundled_app" } stub_const "ASourcePlugin", Class.new(Bundler::Plugin::API) ASourcePlugin.source "new_source" @@ -56,16 +56,40 @@ describe Bundler::SourceList do end it "passes the provided options to the new source" do + @new_source = source_list.add_git_source("uri" => "git://host/path.git") expect(@new_source.options).to eq("uri" => "git://host/path.git") end it "adds the source to the beginning of git_sources" do + @new_source = source_list.add_git_source("uri" => "git://host/path.git") expect(source_list.git_sources.first).to equal(@new_source) end it "removes existing duplicates" do + @duplicate = source_list.add_git_source("uri" => "git://host/path.git") + @new_source = source_list.add_git_source("uri" => "git://host/path.git") expect(source_list.git_sources).not_to include equal(@duplicate) end + + context "with the git: protocol" do + let(:msg) do + "The git source `git://existing-git.org/path.git` " \ + "uses the `git` protocol, which transmits data without encryption. " \ + "Disable this warning with `bundle config git.allow_insecure true`, " \ + "or switch to the `https` protocol to keep your data secure." + end + + it "warns about git protocols" do + expect(Bundler.ui).to receive(:warn).with(msg) + source_list.add_git_source("uri" => "git://existing-git.org/path.git") + end + + it "ignores git protocols on request" do + Bundler.settings["git.allow_insecure"] = true + expect(Bundler.ui).to_not receive(:warn).with(msg) + source_list.add_git_source("uri" => "git://existing-git.org/path.git") + end + end end describe "#add_rubygems_source" do diff --git a/spec/cache/git_spec.rb b/spec/cache/git_spec.rb index f94b1b3469..df77e39cb8 100644 --- a/spec/cache/git_spec.rb +++ b/spec/cache/git_spec.rb @@ -60,7 +60,7 @@ end bundle "#{cmd} --all" bundle "#{cmd} --all" - expect(err).to eq("") + expect(err).to lack_errors FileUtils.rm_rf lib_path("foo-1.0") should_be_installed "foo 1.0" end diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index 338f07100a..c400d7ecae 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -48,7 +48,7 @@ describe "bundle binstubs <gem>" do bundle "binstubs" expect(exitstatus).to eq(1) if exitstatus - expect(out).to eq("`bundle binstubs` needs at least one gem to run.") + expect(out).to include("`bundle binstubs` needs at least one gem to run.") end it "does not bundle the bundler binary" do @@ -59,7 +59,7 @@ describe "bundle binstubs <gem>" do bundle "binstubs bundler" expect(bundled_app("bin/bundle")).not_to exist - expect(out).to eq("Sorry, Bundler can only be run via Rubygems.") + expect(out).to include("Sorry, Bundler can only be run via Rubygems.") end it "installs binstubs from git gems" do @@ -115,7 +115,7 @@ describe "bundle binstubs <gem>" do bundle "binstubs doesnt_exist" expect(exitstatus).to eq(7) if exitstatus - expect(out).to eq("Could not find gem 'doesnt_exist'.") + expect(out).to include("Could not find gem 'doesnt_exist'.") end end diff --git a/spec/commands/check_spec.rb b/spec/commands/check_spec.rb index 9f2053e15b..a1634566a3 100644 --- a/spec/commands/check_spec.rb +++ b/spec/commands/check_spec.rb @@ -10,7 +10,7 @@ describe "bundle check" do bundle :check expect(exitstatus).to eq(0) if exitstatus - expect(out).to eq("The Gemfile's dependencies are satisfied") + expect(out).to include("The Gemfile's dependencies are satisfied") end it "works with the --gemfile flag when not in the directory" do @@ -21,7 +21,7 @@ describe "bundle check" do Dir.chdir tmp bundle "check --gemfile bundled_app/Gemfile" - expect(out).to eq("The Gemfile's dependencies are satisfied") + expect(out).to include("The Gemfile's dependencies are satisfied") end it "creates a Gemfile.lock by default if one does not exist" do @@ -153,7 +153,7 @@ describe "bundle check" do G bundle :check - expect(out).to eq("The Gemfile's dependencies are satisfied") + expect(out).to include("The Gemfile's dependencies are satisfied") end it "works with env conditionals" do @@ -184,7 +184,7 @@ describe "bundle check" do G bundle :check - expect(out).to eq("The Gemfile's dependencies are satisfied") + expect(out).to include("The Gemfile's dependencies are satisfied") end it "outputs an error when the default Gemfile is not found" do @@ -211,7 +211,7 @@ describe "bundle check" do 3.times do bundle :check expect(out).to eq(last_out) - expect(err).to be_empty + expect(err).to lack_errors end end @@ -243,7 +243,7 @@ describe "bundle check" do it "returns success" do bundle "check --path vendor/bundle" expect(exitstatus).to eq(0) if exitstatus - expect(out).to eq("The Gemfile's dependencies are satisfied") + expect(out).to include("The Gemfile's dependencies are satisfied") end it "should write to .bundle/config" do @@ -279,7 +279,7 @@ describe "bundle check" do bundle :install bundle :check expect(exitstatus).to eq(0) if exitstatus - expect(out).to eq("The Gemfile's dependencies are satisfied") + expect(out).to include("The Gemfile's dependencies are satisfied") end it "shows what is missing with the current Gemfile if it is not satisfied" do @@ -332,7 +332,7 @@ describe "bundle check" do lockfile lock_with(Bundler::VERSION.succ) bundle :check expect(out).to include("Bundler is older than the version that created the lockfile") - expect(err).to eq("") + expect(err).to lack_errors lockfile_should_be lock_with(Bundler::VERSION.succ) end end diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb index 37f569b267..67d70b511c 100644 --- a/spec/commands/clean_spec.rb +++ b/spec/commands/clean_spec.rb @@ -37,7 +37,7 @@ describe "bundle clean" do bundle :clean - expect(out).to eq("Removing foo (1.0)") + expect(out).to include("Removing foo (1.0)") should_have_gems "thin-1.0", "rack-1.0.0" should_not_have_gems "foo-1.0" @@ -65,7 +65,7 @@ describe "bundle clean" do bundle :clean - expect(out).to eq("Removing rack (0.9.1)") + expect(out).to include("Removing rack (0.9.1)") should_have_gems "foo-1.0", "rack-1.0.0" should_not_have_gems "rack-0.9.1" @@ -93,7 +93,7 @@ describe "bundle clean" do bundle :clean - expect(out).to eq("Removing rack (1.0.0)") + expect(out).to include("Removing rack (1.0.0)") should_have_gems "foo-1.0", "rack-0.9.1" should_not_have_gems "rack-1.0.0" @@ -116,7 +116,7 @@ describe "bundle clean" do bundle "install --without test_group" bundle :clean - expect(out).to eq("Removing rack (1.0.0)") + expect(out).to include("Removing rack (1.0.0)") should_have_gems "foo-1.0" should_not_have_gems "rack-1.0.0" @@ -171,7 +171,7 @@ describe "bundle clean" do bundle :clean - expect(out).to eq("Removing foo (#{revision[0..11]})") + expect(out).to include("Removing foo (#{revision[0..11]})") expect(vendored_gems("gems/rack-1.0.0")).to exist expect(vendored_gems("bundler/gems/foo-#{revision[0..11]}")).not_to exist @@ -204,7 +204,7 @@ describe "bundle clean" do bundle "update" bundle :clean - expect(out).to eq("Removing foo-bar (#{revision[0..11]})") + expect(out).to include("Removing foo-bar (#{revision[0..11]})") expect(vendored_gems("gems/rack-1.0.0")).to exist expect(vendored_gems("bundler/gems/foo-bar-#{revision[0..11]}")).not_to exist @@ -228,7 +228,7 @@ describe "bundle clean" do bundle "install --path vendor/bundle" bundle :clean - expect(out).to eq("") + expect(out).to include("") expect(vendored_gems("bundler/gems/rails-#{revision[0..11]}")).to exist end @@ -252,7 +252,7 @@ describe "bundle clean" do bundle :clean - expect(out).to eq("") + expect(out).to include("") expect(vendored_gems("bundler/gems/foo-#{revision[0..11]}")).to exist digest = Digest::SHA1.hexdigest(git_path.to_s) expect(vendored_gems("cache/bundler/git/foo-#{digest}")).to_not exist @@ -452,7 +452,7 @@ describe "bundle clean" do bundle :install bundle "clean --force" - expect(out).to eq("Removing foo (1.0)") + expect(out).to include("Removing foo (1.0)") sys_exec "gem list" expect(out).not_to include("foo (1.0)") expect(out).to include("rack (1.0.0)") @@ -587,8 +587,8 @@ describe "bundle clean" do bundle "clean --dry-run" - expect(out).not_to eq("Removing foo (1.0)") - expect(out).to eq("Would have removed foo (1.0)") + expect(out).not_to include("Removing foo (1.0)") + expect(out).to include("Would have removed foo (1.0)") should_have_gems "thin-1.0", "rack-1.0.0", "foo-1.0" @@ -616,8 +616,8 @@ describe "bundle clean" do bundle "clean" - expect(out).to eq("Removing foo (1.0)") - expect(out).not_to eq("Would have removed foo (1.0)") + expect(out).to include("Removing foo (1.0)") + expect(out).not_to include("Would have removed foo (1.0)") should_have_gems "thin-1.0", "rack-1.0.0" should_not_have_gems "foo-1.0" diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index 25b240b0a9..cf10521fac 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -31,7 +31,7 @@ describe "bundle exec" do bundle "exec 'cd #{tmp("gems")} && rackup'" - expect(out).to eq("1.0.0") + expect(out).to include("1.0.0") end it "works when exec'ing something else" do @@ -86,14 +86,14 @@ describe "bundle exec" do expect(out).to eq("Ruby version #{RUBY_VERSION} defaults to keeping non-standard file descriptors on Kernel#exec.") end - expect(err).to eq("") + expect(err).to lack_errors end it "accepts --keep-file-descriptors" do install_gemfile "" bundle "exec --keep-file-descriptors echo foobar" - expect(err).to eq("") + expect(err).to lack_errors end it "can run a command named --verbose" do @@ -179,10 +179,10 @@ describe "bundle exec" do rubylib = rubylib.uniq.join(File::PATH_SEPARATOR) bundle "exec 'echo $RUBYLIB'" - expect(out).to eq(rubylib) + expect(out).to include(rubylib) bundle "exec 'echo $RUBYLIB'", :env => { "RUBYLIB" => rubylib } - expect(out).to eq(rubylib) + expect(out).to include(rubylib) end it "errors nicely when the argument doesn't exist" do @@ -316,12 +316,13 @@ describe "bundle exec" do it "works when unlocked" do bundle "exec 'cd #{tmp("gems")} && rackup'" expect(out).to eq("1.0.0") + expect(out).to include("1.0.0") end it "works when locked" do should_be_locked bundle "exec 'cd #{tmp("gems")} && rackup'" - expect(out).to eq("1.0.0") + expect(out).to include("1.0.0") end end diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb index d4f75eef24..524071d989 100644 --- a/spec/commands/install_spec.rb +++ b/spec/commands/install_spec.rb @@ -17,7 +17,7 @@ describe "bundle install with gem sources" do raise StandardError, "FAIL" G - expect(err).to eq "" + expect(err).to lack_errors expect(out).to match(/StandardError, "FAIL"/) expect(bundled_app("Gemfile.lock")).not_to exist end diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb index b204c6aad5..98eb98a789 100644 --- a/spec/commands/lock_spec.rb +++ b/spec/commands/lock_spec.rb @@ -57,7 +57,7 @@ describe "bundle lock" do it "prints a lockfile when there is no existing lockfile with --print" do bundle "lock --print" - expect(out).to eq(@lockfile) + expect(out).to include(@lockfile) end it "prints a lockfile when there is an existing lockfile with --print" do diff --git a/spec/commands/open_spec.rb b/spec/commands/open_spec.rb index 8ae18cea6a..5507398382 100644 --- a/spec/commands/open_spec.rb +++ b/spec/commands/open_spec.rb @@ -11,17 +11,17 @@ describe "bundle open" do it "opens the gem with BUNDLER_EDITOR as highest priority" do bundle "open rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" } - expect(out).to eq("bundler_editor #{default_bundle_path("gems", "rails-2.3.2")}") + expect(out).to include("bundler_editor #{default_bundle_path("gems", "rails-2.3.2")}") end it "opens the gem with VISUAL as 2nd highest priority" do bundle "open rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "" } - expect(out).to eq("visual #{default_bundle_path("gems", "rails-2.3.2")}") + expect(out).to include("visual #{default_bundle_path("gems", "rails-2.3.2")}") end it "opens the gem with EDITOR as 3rd highest priority" do bundle "open rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } - expect(out).to eq("editor #{default_bundle_path("gems", "rails-2.3.2")}") + expect(out).to include("editor #{default_bundle_path("gems", "rails-2.3.2")}") end it "complains if no EDITOR is set" do @@ -55,7 +55,7 @@ describe "bundle open" do it "opens the gem with short words" do bundle "open rec", :env => { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" } - expect(out).to eq("bundler_editor #{default_bundle_path("gems", "activerecord-2.3.2")}") + expect(out).to include("bundler_editor #{default_bundle_path("gems", "activerecord-2.3.2")}") end it "select the gem from many match gems" do diff --git a/spec/commands/package_spec.rb b/spec/commands/package_spec.rb index 3e4b602963..9c722b3491 100644 --- a/spec/commands/package_spec.rb +++ b/spec/commands/package_spec.rb @@ -266,7 +266,7 @@ describe "bundle install with gem sources" do end bundle :install - expect(err).to be_empty + expect(err).to lack_errors should_be_installed "rack 1.0" end diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb index 43bbc3f945..b4f9c90c95 100644 --- a/spec/commands/show_spec.rb +++ b/spec/commands/show_spec.rb @@ -133,7 +133,7 @@ describe "bundle show" do it "does not output git errors" do bundle :show - expect(err).to be_empty + expect(err).to lack_errors end end diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb index 90a611ddeb..5207278794 100644 --- a/spec/commands/update_spec.rb +++ b/spec/commands/update_spec.rb @@ -274,7 +274,7 @@ describe "bundle update when a gem depends on a newer version of bundler" do it "should not explode" do bundle "update" - expect(err).to be_empty + expect(err).to lack_errors end it "should explain that bundler conflicted" do diff --git a/spec/install/bundler_spec.rb b/spec/install/bundler_spec.rb index 835afa0e96..901c68d2a8 100644 --- a/spec/install/bundler_spec.rb +++ b/spec/install/bundler_spec.rb @@ -112,7 +112,7 @@ describe "bundle install" do rails_fail was resolved to 1.0, which depends on activesupport (= 1.2.3) E - expect(out).to eq(nice_error) + expect(out).to include(nice_error) end it "causes a conflict if a child dependency conflicts with the Gemfile" do @@ -132,7 +132,7 @@ describe "bundle install" do rails_fail was resolved to 1.0, which depends on activesupport (= 1.2.3) E - expect(out).to eq(nice_error) + expect(out).to include(nice_error) end it "can install dependencies with newer bundler version" do diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index 2cb62b424e..4f24a0b162 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -199,7 +199,7 @@ describe "bundle install with git sources" do gem "foo" end G - expect(err).to eq("") + expect(err).to lack_errors run <<-RUBY require 'foo' @@ -852,7 +852,7 @@ describe "bundle install with git sources" do bundle :install, :expect_err => true, :requires => [lib_path("install_hooks.rb")] - expect(err).to eq("Ran pre-install hook: foo-1.0") + expect(err).to eq_err("Ran pre-install hook: foo-1.0") end it "runs post-install hooks" do @@ -872,7 +872,7 @@ describe "bundle install with git sources" do bundle :install, :expect_err => true, :requires => [lib_path("install_hooks.rb")] - expect(err).to eq("Ran post-install hook: foo-1.0") + expect(err).to eq_err("Ran post-install hook: foo-1.0") end it "complains if the install hook fails" do diff --git a/spec/install/gemfile/groups_spec.rb b/spec/install/gemfile/groups_spec.rb index 2f3f446834..7d8768eca9 100644 --- a/spec/install/gemfile/groups_spec.rb +++ b/spec/install/gemfile/groups_spec.rb @@ -26,7 +26,7 @@ describe "bundle install with groups" do puts ACTIVESUPPORT R - expect(err).to eq("ZOMG LOAD ERROR") + expect(err).to eq_err("ZOMG LOAD ERROR") end it "installs gems with inline :groups into those groups" do @@ -37,7 +37,7 @@ describe "bundle install with groups" do puts THIN R - expect(err).to eq("ZOMG LOAD ERROR") + expect(err).to eq_err("ZOMG LOAD ERROR") end it "sets up everything if Bundler.setup is used with no groups" do @@ -58,7 +58,7 @@ describe "bundle install with groups" do puts THIN RUBY - expect(err).to eq("ZOMG LOAD ERROR") + expect(err).to eq_err("ZOMG LOAD ERROR") end it "sets up old groups when they have previously been removed" do @@ -365,7 +365,7 @@ describe "bundle install with groups" do it "does not hit the remote a second time" do FileUtils.rm_rf gem_repo2 bundle "install --without rack" - expect(err).to be_empty + expect(err).to lack_errors end end end diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb index 39b0aed788..50fc1abac5 100644 --- a/spec/install/gemfile/path_spec.rb +++ b/spec/install/gemfile/path_spec.rb @@ -289,7 +289,7 @@ describe "bundle install with explicit source paths" do install_gemfile <<-G gem 'foo', '1.0', :path => "#{lib_path("foo-1.0")}" G - expect(err).to eq("") + expect(err).to lack_errors end it "removes the .gem file after installing" do @@ -551,7 +551,7 @@ describe "bundle install with explicit source paths" do bundle :install, :expect_err => true, :requires => [lib_path("install_hooks.rb")] - expect(err).to eq("Ran pre-install hook: foo-1.0") + expect(err).to eq_err("Ran pre-install hook: foo-1.0") end it "runs post-install hooks" do @@ -571,7 +571,7 @@ describe "bundle install with explicit source paths" do bundle :install, :expect_err => true, :requires => [lib_path("install_hooks.rb")] - expect(err).to eq("Ran post-install hook: foo-1.0") + expect(err).to eq_err("Ran post-install hook: foo-1.0") end it "complains if the install hook fails" do diff --git a/spec/install/gemfile/sources_spec.rb b/spec/install/gemfile/sources_spec.rb index f34a5f2aeb..70ea9e30ce 100644 --- a/spec/install/gemfile/sources_spec.rb +++ b/spec/install/gemfile/sources_spec.rb @@ -26,12 +26,13 @@ describe "bundle install with gems on multiple sources" do gem "rack-obama" gem "rack" G + bundle "config major_deprecations true" end it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first" do bundle :install - expect(out).to include("Warning: this Gemfile contains multiple primary sources.") + expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.") expect(out).to include("Warning: the gem 'rack' was found in multiple sources.") expect(out).to include("Installed from: file:#{gem_repo1}") should_be_installed("rack-obama 1.0.0", "rack 1.0.0") @@ -55,12 +56,13 @@ describe "bundle install with gems on multiple sources" do gem "rack-obama" gem "rack", "1.0.0" # force it to install the working version in repo1 G + bundle "config major_deprecations true" end it "warns about ambiguous gems, but installs anyway" do bundle :install - expect(out).to include("Warning: this Gemfile contains multiple primary sources.") + expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.") expect(out).to include("Warning: the gem 'rack' was found in multiple sources.") expect(out).to include("Installed from: file:#{gem_repo1}") should_be_installed("rack-obama 1.0.0", "rack 1.0.0") @@ -223,8 +225,9 @@ describe "bundle install with gems on multiple sources" do end it "installs from the other source and warns about ambiguous gems" do + bundle "config major_deprecations true" bundle :install - expect(out).to include("Warning: this Gemfile contains multiple primary sources.") + expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.") expect(out).to include("Warning: the gem 'rack' was found in multiple sources.") expect(out).to include("Installed from: file:#{gem_repo2}") should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0") diff --git a/spec/install/gemspecs_spec.rb b/spec/install/gemspecs_spec.rb index aa3085b0d7..58e086b4b2 100644 --- a/spec/install/gemspecs_spec.rb +++ b/spec/install/gemspecs_spec.rb @@ -15,7 +15,7 @@ describe "bundle install" do gem "yaml_spec" G bundle :install - expect(err).to be_empty + expect(err).to lack_errors end it "still installs correctly when using path" do @@ -24,7 +24,7 @@ describe "bundle install" do install_gemfile <<-G gem 'yaml_spec', :path => "#{lib_path("yaml_spec-1.0")}" G - expect(err).to eq("") + expect(err).to lack_errors end end diff --git a/spec/other/cli_dispatch_spec.rb b/spec/other/cli_dispatch_spec.rb index 7aee482bfe..05dac51559 100644 --- a/spec/other/cli_dispatch_spec.rb +++ b/spec/other/cli_dispatch_spec.rb @@ -4,19 +4,19 @@ require "spec_helper" describe "bundle command names" do it "work when given fully" do bundle "install" - expect(err).to eq("") + expect(err).to lack_errors expect(out).not_to match(/Ambiguous command/) end it "work when not ambiguous" do bundle "ins" - expect(err).to eq("") + expect(err).to lack_errors expect(out).not_to match(/Ambiguous command/) end it "print a friendly error when ambiguous" do bundle "in" - expect(err).to eq("") + expect(err).to lack_errors expect(out).to match(/Ambiguous command/) end end diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb index a3d8fd12f4..c2d1cdbeb5 100644 --- a/spec/other/major_deprecation_spec.rb +++ b/spec/other/major_deprecation_spec.rb @@ -2,15 +2,6 @@ require "spec_helper" describe "major deprecations" do - matcher :have_major_deprecation do |expected| - diffable - match do |actual| - actual.split(/^\[DEPRECATED FOR 2\.0\]\s*/).any? do |d| - !d.empty? && values_match?(expected, d.strip) - end - end - end - let(:warnings) { out } # change to err in 2.0 before do @@ -74,5 +65,159 @@ describe "major deprecations" do expect(warnings).not_to have_major_deprecation end end + + describe "bundle install --binstubs" do + it "should output a deprecation warning" do + gemfile <<-G + gem 'rack' + G + + bundle :install, :binstubs => true + expect(warnings).to have_major_deprecation a_string_including("the --binstubs option will be removed") + end + end + end + + context "when bundle is run" do + it "should not warn about gems.rb" do + create_file "gems.rb", <<-G + source "file://#{gem_repo1}" + gem "rack" + G + + bundle :install + expect(err).not_to have_major_deprecation + expect(out).not_to have_major_deprecation + end + + it "should print a Gemfile deprecation warning" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G + + expect(warnings).to have_major_deprecation("gems.rb and gems.locked will be prefered to Gemfile and Gemfile.lock.") + end + + context "with flags" do + it "should print a deprecation warning about autoremembering flags" do + install_gemfile <<-G, :path => "vendor/bundle" + source "file://#{gem_repo1}" + gem "rack" + G + + expect(warnings).to have_major_deprecation a_string_including( + "flags passed to commands will no longer be automatically remembered.") + end + end + end + + context "when Bundler.setup is run in a ruby script" do + it "should print a single deprecation warning" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack", :group => :test + G + + ruby <<-RUBY + require 'rubygems' + require 'bundler' + require 'bundler/vendored_thor' + + Bundler.ui = Bundler::UI::Shell.new + Bundler.setup + Bundler.setup + RUBY + + expect(warnings).to have_major_deprecation("gems.rb and gems.locked will be prefered to Gemfile and Gemfile.lock.") + end + end + + context "when `bundler/deployment` is required in a ruby script" do + it "should print a capistrano deprecation warning" do + ruby(<<-RUBY, :expect_err => true) + require 'bundler/deployment' + RUBY + + expect(warnings).to have_major_deprecation("Bundler no longer integrates " \ + "with Capistrano, but Capistrano provides " \ + "its own integration with Bundler via the " \ + "capistrano-bundler gem. Use it instead.") + end + end + + describe Bundler::Dsl do + before do + @rubygems = double("rubygems") + allow(Bundler::Source::Rubygems).to receive(:new) { @rubygems } + end + + context "with github gems" do + it "warns about the https change" do + msg = "The :github option uses the git: protocol, which is not secure. " \ + "Bundler 2.0 will use the https: protocol, which is secure. Enable this change now by " \ + "running `bundle config github.https true`." + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(msg) + subject.gem("sparks", :github => "indirect/sparks") + end + + it "upgrades to https on request" do + Bundler.settings["github.https"] = true + subject.gem("sparks", :github => "indirect/sparks") + expect(Bundler::SharedHelpers).to receive(:major_deprecation).never + github_uri = "https://github.com/indirect/sparks.git" + expect(subject.dependencies.first.source.uri).to eq(github_uri) + end + end + + context "with bitbucket gems" do + it "warns about removal" do + allow(Bundler.ui).to receive(:deprecate) + msg = "The :bitbucket git source is deprecated, and will be removed " \ + "in Bundler 2.0. Add this code to your Gemfile to ensure it " \ + "continues to work:\n git_source(:bitbucket) do |repo_name|\n " \ + " \"https://\#{user_name}@bitbucket.org/\#{user_name}/\#{repo_name}" \ + ".git\"\n end\n" + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(msg) + subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails") + end + end + + context "with gist gems" do + it "warns about removal" do + allow(Bundler.ui).to receive(:deprecate) + msg = "The :gist git source is deprecated, and will be removed " \ + "in Bundler 2.0. Add this code to your Gemfile to ensure it " \ + "continues to work:\n git_source(:gist) do |repo_name|\n " \ + " \"https://gist.github.com/\#{repo_name}.git\"\n" \ + " end\n" + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(msg) + subject.gem("not-really-a-gem", :gist => "1234") + end + end + end + + context "bundle list" do + it "prints a deprecation warning" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G + + bundle :list + + out.gsub!(/gems included.*?\[DEPRECATED/im, "[DEPRECATED") + + expect(warnings).to have_major_deprecation("use `bundle show` instead of `bundle list`") + end + end + + context "bundle console" do + it "prints a deprecation warning" do + bundle "console" + + expect(warnings).to have_major_deprecation \ + "bundle console will be replaced by `bin/console` generated by `bundle gem <name>`" + end end end diff --git a/spec/realworld/edgecases_spec.rb b/spec/realworld/edgecases_spec.rb index 89de134cc4..5c6835ed39 100644 --- a/spec/realworld/edgecases_spec.rb +++ b/spec/realworld/edgecases_spec.rb @@ -9,7 +9,7 @@ describe "real world edgecases", :realworld => true, :sometimes => true do gem "linecache", "0.46" G bundle :lock - expect(err).to eq("") + expect(err).to lack_errors expect(exitstatus).to eq(0) if exitstatus end @@ -91,7 +91,7 @@ describe "real world edgecases", :realworld => true, :sometimes => true do bundle "install --path vendor/bundle", :expect_err => true expect(err).not_to include("Could not find rake") - expect(err).to be_empty + expect(err).to lack_errors end it "checks out git repos when the lockfile is corrupted" do diff --git a/spec/runtime/inline_spec.rb b/spec/runtime/inline_spec.rb index c815ccbbd3..ccc2aed8be 100644 --- a/spec/runtime/inline_spec.rb +++ b/spec/runtime/inline_spec.rb @@ -91,7 +91,7 @@ describe "bundler/inline#gemfile" do RUBY expect(out).to include("Installing activesupport") - expect(err).to eq("") + expect(err).to lack_errors expect(exitstatus).to be_zero if exitstatus end diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb index 5ddf1ef013..d565be7194 100644 --- a/spec/runtime/require_spec.rb +++ b/spec/runtime/require_spec.rb @@ -120,7 +120,7 @@ describe "Bundler.require" do Bundler.require R - expect(err).to eq("ZOMG LOAD ERROR") + expect(err).to eq_err("ZOMG LOAD ERROR") end it "displays a helpful message if the required gem throws an error" do @@ -157,7 +157,7 @@ describe "Bundler.require" do RUBY run(cmd, :expect_err => true) - expect(err).to eq("ZOMG LOAD ERROR: cannot load such file -- load-bar") + expect(err).to eq_err("ZOMG LOAD ERROR: cannot load such file -- load-bar") end describe "with namespaced gems" do @@ -193,7 +193,7 @@ describe "Bundler.require" do RUBY ruby(cmd, :expect_err => true) - expect(err).to be_empty + expect(err).to lack_errors end it "does not mangle explictly given requires" do @@ -205,7 +205,7 @@ describe "Bundler.require" do load_error_run <<-R, "jquery-rails" Bundler.require R - expect(err).to eq("ZOMG LOAD ERROR") + expect(err).to eq_err("ZOMG LOAD ERROR") end it "handles the case where regex fails" do @@ -227,7 +227,7 @@ describe "Bundler.require" do RUBY run(cmd, :expect_err => true) - expect(err).to eq("ZOMG LOAD ERROR") + expect(err).to eq_err("ZOMG LOAD ERROR") end it "doesn't swallow the error when the library has an unrelated error" do @@ -250,7 +250,7 @@ describe "Bundler.require" do RUBY run(cmd, :expect_err => true) - expect(err).to eq("ZOMG LOAD ERROR: cannot load such file -- load-bar") + expect(err).to eq_err("ZOMG LOAD ERROR: cannot load such file -- load-bar") end end @@ -356,7 +356,7 @@ describe "Bundler.require" do load_error_run <<-R, "no_such_file_omg" Bundler.require R - expect(err).to eq("ZOMG LOAD ERROR") + expect(err).to eq_err("ZOMG LOAD ERROR") end end end @@ -375,7 +375,7 @@ describe "Bundler.require with platform specific dependencies" do G run "Bundler.require", :expect_err => true - expect(err).to be_empty + expect(err).to lack_errors end it "requires gems pinned to multiple platforms, including the current one" do @@ -390,6 +390,6 @@ describe "Bundler.require with platform specific dependencies" do run "Bundler.require; puts RACK", :expect_err => true expect(out).to eq("1.0.0") - expect(err).to be_empty + expect(err).to lack_errors end end diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index aa74d83ba4..18abf0549e 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -17,7 +17,7 @@ describe "Bundler.setup" do require 'rack' puts RACK RUBY - expect(err).to eq("") + expect(err).to lack_errors expect(out).to eq("1.0.0") end end @@ -43,7 +43,7 @@ describe "Bundler.setup" do puts "WIN" end RUBY - expect(err).to eq("") + expect(err).to lack_errors expect(out).to eq("WIN") end @@ -56,7 +56,7 @@ describe "Bundler.setup" do require 'rack' puts RACK RUBY - expect(err).to eq("") + expect(err).to lack_errors expect(out).to eq("1.0.0") end @@ -70,7 +70,7 @@ describe "Bundler.setup" do require 'rack' puts RACK RUBY - expect(err).to eq("") + expect(err).to lack_errors expect(out).to eq("1.0.0") end @@ -88,7 +88,7 @@ describe "Bundler.setup" do puts "FAIL" end RUBY - expect(err).to eq("") + expect(err).to lack_errors expect(out).to match("WIN") end @@ -305,7 +305,7 @@ describe "Bundler.setup" do end R - expect(err).to be_empty + expect(err).to lack_errors end it "replaces #gem but raises when the version is wrong" do @@ -331,7 +331,7 @@ describe "Bundler.setup" do end R - expect(err).to be_empty + expect(err).to lack_errors end end @@ -647,7 +647,7 @@ describe "Bundler.setup" do end R - expect(err).to be_empty + expect(err).to lack_errors end end end @@ -682,7 +682,7 @@ describe "Bundler.setup" do ENV["GEM_HOME"] = "" bundle %(exec ruby -e "require 'set'") - expect(err).to be_empty + expect(err).to lack_errors end it "should prepend gemspec require paths to $LOAD_PATH in order" do @@ -771,7 +771,7 @@ describe "Bundler.setup" do require 'foo' R end - expect(err).to eq("") + expect(err).to lack_errors end it "should make sure the Bundler.root is really included in the path relative to the Gemfile" do @@ -796,7 +796,7 @@ describe "Bundler.setup" do R end - expect(err).to eq("") + expect(err).to lack_errors end end @@ -943,7 +943,7 @@ describe "Bundler.setup" do Bundler.load RUBY - expect(err).to eq("") + expect(err).to lack_errors expect(out).to eq("") end end @@ -955,7 +955,7 @@ describe "Bundler.setup" do G bundle %(exec ruby -e "require 'bundler'; Bundler.setup") - expect(err).to be_empty + expect(err).to lack_errors end end diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index 1a05c76637..10e47691ab 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -1,6 +1,31 @@ # frozen_string_literal: true module Spec module Matchers + MAJOR_DEPRECATION = /^\[DEPRECATED FOR 2\.0\]\s*/ + + RSpec::Matchers.define :lack_errors do + diffable + match do |actual| + actual.gsub(/#{MAJOR_DEPRECATION}.+[\n]?/, "") == "" + end + end + + RSpec::Matchers.define :eq_err do |expected| + diffable + match do |actual| + actual.gsub(/#{MAJOR_DEPRECATION}.+[\n]?/, "") == expected + end + end + + RSpec::Matchers.define :have_major_deprecation do |expected| + diffable + match do |actual| + actual.split(MAJOR_DEPRECATION).any? do |d| + !d.empty? && values_match?(expected, d.strip) + end + end + end + RSpec::Matchers.define :have_dep do |*args| dep = Bundler::Dependency.new(*args) @@ -34,7 +59,8 @@ module Spec version_const = name == "bundler" ? "Bundler::VERSION" : Spec::Builders.constantize(name) run! "require '#{name}.rb'; puts #{version_const}", *groups expect(out).not_to be_empty, "#{name} is not installed" - actual_version, actual_platform = out.split(/\s+/, 2) + out.gsub!(/#{MAJOR_DEPRECATION}.*$/, "") + actual_version, actual_platform = out.strip.split(/\s+/, 2) expect(Gem::Version.new(actual_version)).to eq(Gem::Version.new(version)) expect(actual_platform).to eq(platform) end diff --git a/spec/update/git_spec.rb b/spec/update/git_spec.rb index 644bbad80c..25dff6818e 100644 --- a/spec/update/git_spec.rb +++ b/spec/update/git_spec.rb @@ -90,7 +90,7 @@ describe "bundle update" do gem "foo", "1.0", :git => "#{lib_path("foo_two")}" G - expect(err).to be_empty + expect(err).to lack_errors expect(out).to include("Fetching #{lib_path}/foo_two") expect(out).to include("Bundle complete!") end |