summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Lance <stefan@lances.net>2015-03-20 20:09:12 -0500
committerSamuel E. Giddins <segiddins@segiddins.me>2015-07-16 08:17:00 -0700
commitd60f7e6679d974f84aefc16a2c5a8c162cb00dc5 (patch)
treecc719789a409e1da2c0cc9ab5852d7d250b9a7d3
parentb63b3a3932dd0c6341a21583927dd6cdfdd7739e (diff)
downloadbundler-d60f7e6679d974f84aefc16a2c5a8c162cb00dc5.tar.gz
Add Bundler.ui.deprecate
-rwxr-xr-xexe/bundle_ruby3
-rw-r--r--lib/bundler/shared_helpers.rb5
-rw-r--r--lib/bundler/ui/shell.rb10
-rw-r--r--lib/bundler/ui/silent.rb3
-rw-r--r--spec/bundler/bundler_spec.rb42
-rw-r--r--spec/cache/git_spec.rb2
-rw-r--r--spec/commands/binstubs_spec.rb6
-rw-r--r--spec/commands/check_spec.rb14
-rw-r--r--spec/commands/clean_spec.rb26
-rw-r--r--spec/commands/exec_spec.rb13
-rw-r--r--spec/commands/install_spec.rb2
-rw-r--r--spec/commands/lock_spec.rb2
-rw-r--r--spec/commands/open_spec.rb8
-rw-r--r--spec/commands/package_spec.rb2
-rw-r--r--spec/commands/show_spec.rb2
-rw-r--r--spec/commands/update_spec.rb2
-rw-r--r--spec/install/bundler_spec.rb4
-rw-r--r--spec/install/gemfile/git_spec.rb6
-rw-r--r--spec/install/gemfile/path_spec.rb6
-rw-r--r--spec/install/gems/groups_spec.rb8
-rw-r--r--spec/install/gemspecs_spec.rb4
-rw-r--r--spec/other/bundle_ruby_spec.rb4
-rw-r--r--spec/other/cli_dispatch_spec.rb8
-rw-r--r--spec/realworld/edgecases_spec.rb4
-rw-r--r--spec/runtime/require_spec.rb18
-rw-r--r--spec/runtime/setup_spec.rb26
-rw-r--r--spec/support/matchers.rb12
-rw-r--r--spec/update/git_spec.rb2
28 files changed, 155 insertions, 89 deletions
diff --git a/exe/bundle_ruby b/exe/bundle_ruby
index 734e5a7874..bd239b4eff 100755
--- a/exe/bundle_ruby
+++ b/exe/bundle_ruby
@@ -41,7 +41,8 @@ module Bundler
end
end
-STDERR.puts "Warning: bundle_ruby will be deprecated in Bundler 2.0.0."
+STDERR.puts "Warning: bundle_ruby is deprecated and will be removed in " \
+ "Bundler 2.0.0."
dsl = Bundler::Dsl.new
begin
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 3368912343..eaca895b4b 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -18,8 +18,12 @@ end
module Bundler
module SharedHelpers
attr_accessor :gem_loaded
+ @@warning_printed = false
def default_gemfile
+ Bundler.ui.deprecate("Gemfile and Gemfile.lock are " \
+ "deprecated and will be replaced with gems.rb and " \
+ "gems.locked in Bundler 2.0.0.\n")
gemfile = find_gemfile
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
Pathname.new(gemfile)
@@ -97,7 +101,6 @@ module Bundler
def find_gemfile
given = ENV["BUNDLE_GEMFILE"]
return given if given && !given.empty?
-
find_file("Gemfile", "gems.rb")
end
diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb
index 92af57756c..24e5df0ae6 100644
--- a/lib/bundler/ui/shell.rb
+++ b/lib/bundler/ui/shell.rb
@@ -5,7 +5,7 @@ module Bundler
class Shell
LEVELS = %w(silent error warn confirm info debug)
- attr_writer :shell
+ attr_writer :shell, :deprecation_messages
def initialize(options = {})
if options["no-color"] || !STDOUT.tty?
@@ -14,6 +14,7 @@ module Bundler
@shell = Thor::Base.shell.new
@level = ENV["DEBUG"] ? "debug" : "info"
@warning_history = []
+ @deprecation_messages = Set.new
end
def info(msg, newline = nil)
@@ -30,6 +31,13 @@ module Bundler
tell_me(msg, :yellow, newline) if level("warn")
end
+ def deprecate(msg, newline = nil)
+ unless @deprecation_messages.include?(msg)
+ @deprecation_messages.add(msg)
+ warn("DEPRECATION: " + msg, newline)
+ end
+ end
+
def error(msg, newline = nil)
tell_me(msg, :red, newline) if level("error")
end
diff --git a/lib/bundler/ui/silent.rb b/lib/bundler/ui/silent.rb
index 3eb3199b5c..84a672cc37 100644
--- a/lib/bundler/ui/silent.rb
+++ b/lib/bundler/ui/silent.rb
@@ -10,6 +10,9 @@ module Bundler
def warn(message, newline = nil)
end
+ def deprecate(message)
+ end
+
def error(message, newline = nil)
end
diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb
index ff7db3d968..cd924df07c 100644
--- a/spec/bundler/bundler_spec.rb
+++ b/spec/bundler/bundler_spec.rb
@@ -4,6 +4,45 @@ require "bundler"
describe Bundler do
describe "version 1.99" do
+ context "when bundle is run" do
+ it "should print a single deprecation warning" do
+ # install_gemfile calls `bundle :install, opts`
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ expect(out).to include("DEPRECATION: Gemfile and Gemfile.lock are " \
+ "deprecated and will be replaced with gems.rb and gems.locked in " \
+ "Bundler 2.0.0.")
+ expect(err).to lack_errors
+ 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(out).to eq("DEPRECATION: Gemfile and Gemfile.lock are " \
+ "deprecated and will be replaced with gems.rb and gems.locked in " \
+ "Bundler 2.0.0.")
+ expect(err).to lack_errors
+ end
+ end
+
context "when `bundler/deployment` is required in a ruby script" do
it "should print a capistrano deprecation warning" do
install_gemfile <<-G
@@ -11,7 +50,7 @@ describe Bundler do
gem "rack", :group => :test
G
- ruby(<<-RUBY, { expect_err: true })
+ ruby(<<-RUBY, { :expect_err => true })
require 'bundler/deployment'
RUBY
@@ -22,7 +61,6 @@ describe Bundler do
expect(err).to lack_errors
end
end
-
end
describe "#load_gemspec_uncached" do
diff --git a/spec/cache/git_spec.rb b/spec/cache/git_spec.rb
index 3ac19f6bc5..0d6fa22063 100644
--- a/spec/cache/git_spec.rb
+++ b/spec/cache/git_spec.rb
@@ -59,7 +59,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 422297e3ae..bd4e5ba806 100644
--- a/spec/commands/binstubs_spec.rb
+++ b/spec/commands/binstubs_spec.rb
@@ -47,7 +47,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
@@ -58,7 +58,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
@@ -114,7 +114,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 1bd697f8aa..564657f555 100644
--- a/spec/commands/check_spec.rb
+++ b/spec/commands/check_spec.rb
@@ -9,7 +9,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
@@ -20,7 +20,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
@@ -152,7 +152,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
@@ -183,7 +183,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
@@ -210,7 +210,7 @@ describe "bundle check" do
3.times do |i|
bundle :check
expect(out).to eq(last_out)
- expect(err).to be_empty
+ expect(err).to lack_errors
end
end
@@ -242,7 +242,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
@@ -278,7 +278,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
diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb
index f3f1bbee3a..780bbba238 100644
--- a/spec/commands/clean_spec.rb
+++ b/spec/commands/clean_spec.rb
@@ -36,7 +36,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"
@@ -64,7 +64,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"
@@ -92,7 +92,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"
@@ -115,7 +115,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"
@@ -170,7 +170,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
@@ -203,7 +203,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
@@ -227,7 +227,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
@@ -251,7 +251,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
@@ -451,7 +451,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)")
@@ -552,8 +552,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"
@@ -581,8 +581,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 dbaed9bcf7..dfff9bea18 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -30,7 +30,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
@@ -85,14 +85,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
@@ -178,10 +178,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
@@ -227,12 +227,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 2e1a206f21..9c5560bcc5 100644
--- a/spec/commands/install_spec.rb
+++ b/spec/commands/install_spec.rb
@@ -16,7 +16,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 0e916cdd1a..d476867bb6 100644
--- a/spec/commands/lock_spec.rb
+++ b/spec/commands/lock_spec.rb
@@ -56,7 +56,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 1880ae3063..7a933d72b4 100644
--- a/spec/commands/open_spec.rb
+++ b/spec/commands/open_spec.rb
@@ -10,17 +10,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
@@ -54,7 +54,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 d890afc995..c3bec9de57 100644
--- a/spec/commands/package_spec.rb
+++ b/spec/commands/package_spec.rb
@@ -100,7 +100,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 1e24f11347..d5ad8be79f 100644
--- a/spec/commands/show_spec.rb
+++ b/spec/commands/show_spec.rb
@@ -121,7 +121,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 2f3e41b67e..a06cb8696f 100644
--- a/spec/commands/update_spec.rb
+++ b/spec/commands/update_spec.rb
@@ -167,7 +167,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 930d7095fc..2c8c55d4db 100644
--- a/spec/install/bundler_spec.rb
+++ b/spec/install/bundler_spec.rb
@@ -104,7 +104,7 @@ describe "bundle install" do
rails_fail (>= 0) ruby depends on
activesupport (= 1.2.3) ruby
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
@@ -124,7 +124,7 @@ describe "bundle install" do
activesupport (= 2.3.5) ruby
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 6baaf5f301..dfda56c683 100644
--- a/spec/install/gemfile/git_spec.rb
+++ b/spec/install/gemfile/git_spec.rb
@@ -161,7 +161,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'
@@ -797,7 +797,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
@@ -817,7 +817,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/path_spec.rb b/spec/install/gemfile/path_spec.rb
index 837a3d4744..be7c0f9564 100644
--- a/spec/install/gemfile/path_spec.rb
+++ b/spec/install/gemfile/path_spec.rb
@@ -285,7 +285,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
@@ -495,7 +495,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
@@ -515,7 +515,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/gems/groups_spec.rb b/spec/install/gems/groups_spec.rb
index d64e03186d..89d3eb0cdb 100644
--- a/spec/install/gems/groups_spec.rb
+++ b/spec/install/gems/groups_spec.rb
@@ -25,7 +25,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
@@ -36,7 +36,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
@@ -57,7 +57,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
@@ -364,7 +364,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/gemspecs_spec.rb b/spec/install/gemspecs_spec.rb
index 4300a16cb2..0d9a36d98d 100644
--- a/spec/install/gemspecs_spec.rb
+++ b/spec/install/gemspecs_spec.rb
@@ -14,7 +14,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
@@ -23,7 +23,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/bundle_ruby_spec.rb b/spec/other/bundle_ruby_spec.rb
index 1f55ebd92d..73e37d9696 100644
--- a/spec/other/bundle_ruby_spec.rb
+++ b/spec/other/bundle_ruby_spec.rb
@@ -12,8 +12,8 @@ describe "bundle_ruby" do
bundle_ruby
- expect(err).to eq("Warning: bundle_ruby will be deprecated in " \
- "Bundler 2.0.0.")
+ expect(err).to eq_err("Warning: bundle_ruby is deprecated and will " \
+ "be removed in Bundler 2.0.0.")
end
end
diff --git a/spec/other/cli_dispatch_spec.rb b/spec/other/cli_dispatch_spec.rb
index 0dd49c7a40..c8556e08a2 100644
--- a/spec/other/cli_dispatch_spec.rb
+++ b/spec/other/cli_dispatch_spec.rb
@@ -3,19 +3,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("")
+ bundle "i"
+ expect(err).to lack_errors
expect(out).to match(/Ambiguous command/)
end
end
diff --git a/spec/realworld/edgecases_spec.rb b/spec/realworld/edgecases_spec.rb
index 028c30c293..0aca36e4ea 100644
--- a/spec/realworld/edgecases_spec.rb
+++ b/spec/realworld/edgecases_spec.rb
@@ -7,7 +7,7 @@ describe "real world edgecases", :realworld => true do
source :rubygems
gem "linecache", "0.46"
G
- expect(err).to eq("")
+ expect(err).to lack_errors
end
# https://github.com/bundler/bundler/issues/1202
@@ -82,7 +82,7 @@ describe "real world edgecases", :realworld => 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/require_spec.rb b/spec/runtime/require_spec.rb
index cf75fe08d3..e2beee61d2 100644
--- a/spec/runtime/require_spec.rb
+++ b/spec/runtime/require_spec.rb
@@ -95,7 +95,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 "doesn't swallow the error when the library has an unrelated error" do
@@ -117,7 +117,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
@@ -153,7 +153,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
@@ -165,7 +165,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
@@ -187,7 +187,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
@@ -210,7 +210,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
@@ -316,7 +316,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
@@ -335,7 +335,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
@@ -350,6 +350,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 9bee4fabb7..918809212b 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -16,7 +16,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
@@ -42,7 +42,7 @@ describe "Bundler.setup" do
puts "WIN"
end
RUBY
- expect(err).to eq("")
+ expect(err).to lack_errors
expect(out).to eq("WIN")
end
@@ -55,7 +55,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
@@ -69,7 +69,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
@@ -87,7 +87,7 @@ describe "Bundler.setup" do
puts "FAIL"
end
RUBY
- expect(err).to eq("")
+ expect(err).to lack_errors
expect(out).to match("WIN")
end
@@ -245,7 +245,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
@@ -271,7 +271,7 @@ describe "Bundler.setup" do
end
R
- expect(err).to be_empty
+ expect(err).to lack_errors
end
end
@@ -587,7 +587,7 @@ describe "Bundler.setup" do
end
R
- expect(err).to be_empty
+ expect(err).to lack_errors
end
end
end
@@ -622,7 +622,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
@@ -711,7 +711,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
@@ -736,7 +736,7 @@ describe "Bundler.setup" do
R
end
- expect(err).to eq("")
+ expect(err).to lack_errors
end
end
@@ -883,7 +883,7 @@ describe "Bundler.setup" do
Bundler.load
RUBY
- expect(err).to eq("")
+ expect(err).to lack_errors
expect(out).to eq("")
end
end
@@ -895,7 +895,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 b4b18e7839..f0382cfd7b 100644
--- a/spec/support/matchers.rb
+++ b/spec/support/matchers.rb
@@ -1,5 +1,17 @@
module Spec
module Matchers
+ RSpec::Matchers.define :lack_errors do
+ match do |actual|
+ actual.gsub(/(^DEPRECATION:.+)/, "") == ""
+ end
+ end
+
+ RSpec::Matchers.define :eq_err do |expected|
+ match do |actual|
+ actual.gsub(/(^DEPRECATION:.+\n)/, "") == expected
+ end
+ end
+
RSpec::Matchers.define :have_dep do |*args|
dep = Bundler::Dependency.new(*args)
diff --git a/spec/update/git_spec.rb b/spec/update/git_spec.rb
index 5743501032..6c4c984c8f 100644
--- a/spec/update/git_spec.rb
+++ b/spec/update/git_spec.rb
@@ -89,7 +89,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