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 /spec | |
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?
Diffstat (limited to 'spec')
26 files changed, 296 insertions, 97 deletions
diff --git a/spec/bundler/source_list_spec.rb b/spec/bundler/source_list_spec.rb index 56f17f9a..3657ac09 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 f94b1b34..df77e39c 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 338f0710..c400d7ec 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 9f2053e1..a1634566 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 37f569b2..67d70b51 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 25b240b0..cf10521f 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 d4f75eef..524071d9 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 b204c6aa..98eb98a7 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 8ae18cea..55073983 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 3e4b6029..9c722b34 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 43bbc3f9..b4f9c90c 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 90a611dd..52072787 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 835afa0e..901c68d2 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 2cb62b42..4f24a0b1 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 2f3f4468..7d8768ec 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 39b0aed7..50fc1aba 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 f34a5f2a..70ea9e30 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 aa3085b0..58e086b4 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 7aee482b..05dac515 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 a3d8fd12..c2d1cdbe 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 89de134c..5c6835ed 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 c815ccbb..ccc2aed8 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 5ddf1ef0..d565be71 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 aa74d83b..18abf054 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 1a05c766..10e47691 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 644bbad8..25dff681 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 |