summaryrefslogtreecommitdiff
path: root/spec/commands
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-04-14 12:04:15 +0000
committerBundlerbot <bot@bundler.io>2019-04-14 12:04:15 +0000
commit9424cedb913b738bbd733e30c772524ea054f5fe (patch)
tree8bd3e0dbedcacd4e05d1126c819807ece21dbd3e /spec/commands
parenta53709556b95a914e874b22ed2116a46b0528852 (diff)
parentc494e1261268a5249b6406fe35709016f7c4c3ac (diff)
downloadbundler-9424cedb913b738bbd733e30c772524ea054f5fe.tar.gz
Merge #6730
6730: Print errors to stderr by default, and remove configuration option r=greysteil a=greysteil ### What was the end-user problem that led to this PR? The problem was #6729 - Bundler unexpectedly outputs error and warning messages to STDOUT. ### What was your diagnosis of the problem? My diagnosis was that whilst very minorly breaking, this is essentially a bug fix, and should be considered for inclusion for Bundler 2.0 even if very few other breaking changes are. ### What is your fix for the problem, implemented in this PR? My fix was so switch output for warning and error messages to STDERR, and remove the configuration option (as is redundant once the setup is flipped - anyone wanting to redirect those message to STDOUT could do so in their shell). ### Why did you choose this fix out of the possible options? I chose this fix because I think the new behaviour is what everyone would expect, and we should get it out from behind its feature switch sooner rather than later. Alternatively, we might want to keep the Bundler 2.0 release "purer" by only dropping Ruby versions in it - that's totally fine too, but I figured we should have the code to discus #6729, rather than doing it in abstract. Co-authored-by: Grey Baker <greysteil@gmail.com> Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
Diffstat (limited to 'spec/commands')
-rw-r--r--spec/commands/add_spec.rb2
-rw-r--r--spec/commands/binstubs_spec.rb18
-rw-r--r--spec/commands/check_spec.rb2
-rw-r--r--spec/commands/config_spec.rb38
-rw-r--r--spec/commands/exec_spec.rb22
-rw-r--r--spec/commands/init_spec.rb2
-rw-r--r--spec/commands/install_spec.rb4
-rw-r--r--spec/commands/lock_spec.rb2
-rw-r--r--spec/commands/newgem_spec.rb12
-rw-r--r--spec/commands/package_spec.rb2
-rw-r--r--spec/commands/update_spec.rb6
11 files changed, 55 insertions, 55 deletions
diff --git a/spec/commands/add_spec.rb b/spec/commands/add_spec.rb
index dac1d0f6b9..7d435916db 100644
--- a/spec/commands/add_spec.rb
+++ b/spec/commands/add_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe "bundle add" do
it "shows error" do
bundle "add"
- expect(last_command.bundler_err).to include("Please specify gems to add")
+ expect(err).to include("Please specify gems to add")
end
end
diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb
index 3f62f17b45..77f23b9a2f 100644
--- a/spec/commands/binstubs_spec.rb
+++ b/spec/commands/binstubs_spec.rb
@@ -70,7 +70,7 @@ RSpec.describe "bundle binstubs <gem>" do
bundle "binstubs rack", :all => true
expect(last_command).to be_failure
- expect(last_command.bundler_err).to include("Cannot specify --all with specific gems")
+ expect(err).to include("Cannot specify --all with specific gems")
end
context "when generating bundle binstub outside bundler" do
@@ -88,7 +88,7 @@ RSpec.describe "bundle binstubs <gem>" do
sys_exec "bin/rackup"
- expect(last_command.stderr).to include("was not generated by Bundler")
+ expect(err).to include("was not generated by Bundler")
end
end
@@ -135,7 +135,7 @@ RSpec.describe "bundle binstubs <gem>" do
it "runs the correct version of bundler" do
sys_exec "#{bundled_app("bin/bundle")} install", "BUNDLER_VERSION" => "999.999.999"
expect(exitstatus).to eq(42) if exitstatus
- expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:").
+ expect(err).to include("Activating bundler (999.999.999) failed:").
and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`")
end
end
@@ -145,7 +145,7 @@ RSpec.describe "bundle binstubs <gem>" do
lockfile lockfile.gsub(system_bundler_version, "999.999.999")
sys_exec "#{bundled_app("bin/bundle")} install"
expect(exitstatus).to eq(42) if exitstatus
- expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:").
+ expect(err).to include("Activating bundler (999.999.999) failed:").
and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`")
end
@@ -154,7 +154,7 @@ RSpec.describe "bundle binstubs <gem>" do
lockfile lockfile.gsub(system_bundler_version, "44.0")
sys_exec "#{bundled_app("bin/bundle")} install"
expect(exitstatus).to eq(42) if exitstatus
- expect(last_command.stderr).to include("Activating bundler (44.0) failed:").
+ expect(err).to include("Activating bundler (44.0) failed:").
and include("To install the version of bundler this project requires, run `gem install bundler -v '44.0'`")
end
@@ -163,7 +163,7 @@ RSpec.describe "bundle binstubs <gem>" do
lockfile lockfile.gsub(system_bundler_version, "2.12.0.a")
sys_exec "#{bundled_app("bin/bundle")} install"
expect(exitstatus).to eq(42) if exitstatus
- expect(last_command.stderr).to include("Activating bundler (2.12.0.a) failed:").
+ expect(err).to include("Activating bundler (2.12.0.a) failed:").
and include("To install the version of bundler this project requires, run `gem install bundler -v '2.12.0.a'`")
end
end
@@ -173,13 +173,13 @@ RSpec.describe "bundle binstubs <gem>" do
it "calls through to the latest bundler version" do
sys_exec! "#{bundled_app("bin/bundle")} update --bundler"
- expect(last_command.stdout).to eq %(system bundler #{system_bundler_version}\n["update", "--bundler"])
+ expect(out).to eq %(system bundler #{system_bundler_version}\n["update", "--bundler"])
end
it "calls through to the explicit bundler version" do
sys_exec "#{bundled_app("bin/bundle")} update --bundler=999.999.999"
expect(exitstatus).to eq(42) if exitstatus
- expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:").
+ expect(err).to include("Activating bundler (999.999.999) failed:").
and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`")
end
end
@@ -205,7 +205,7 @@ RSpec.describe "bundle binstubs <gem>" do
it "attempts to load that version", :ruby_repo do
sys_exec bundled_app("bin/rackup").to_s
expect(exitstatus).to eq(42) if exitstatus
- expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:").
+ expect(err).to include("Activating bundler (999.999.999) failed:").
and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`")
end
end
diff --git a/spec/commands/check_spec.rb b/spec/commands/check_spec.rb
index 7114610644..cf88736612 100644
--- a/spec/commands/check_spec.rb
+++ b/spec/commands/check_spec.rb
@@ -338,7 +338,7 @@ RSpec.describe "bundle check" do
it "does not change the lock but warns" do
lockfile lock_with(Bundler::VERSION.succ)
bundle! :check
- expect(last_command.bundler_err).to include("the running version of Bundler (#{Bundler::VERSION}) is older than the version that created the lockfile (#{Bundler::VERSION.succ})")
+ expect(err).to include("the running version of Bundler (#{Bundler::VERSION}) is older than the version that created the lockfile (#{Bundler::VERSION.succ})")
lockfile_should_be lock_with(Bundler::VERSION.succ)
end
end
diff --git a/spec/commands/config_spec.rb b/spec/commands/config_spec.rb
index 84f882b410..f5b3e7c998 100644
--- a/spec/commands/config_spec.rb
+++ b/spec/commands/config_spec.rb
@@ -391,86 +391,86 @@ E
describe "subcommands" do
it "list" do
bundle! "config list"
- expect(last_command.stdout).to eq "Settings are listed in order of priority. The top value will be used.\nspec_run\nSet via BUNDLE_SPEC_RUN: \"true\""
+ expect(out).to eq "Settings are listed in order of priority. The top value will be used.\nspec_run\nSet via BUNDLE_SPEC_RUN: \"true\""
bundle! "config list", :parseable => true
- expect(last_command.stdout).to eq "spec_run=true"
+ expect(out).to eq "spec_run=true"
end
it "get" do
ENV["BUNDLE_BAR"] = "bar_val"
bundle! "config get foo"
- expect(last_command.stdout).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
+ expect(out).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
ENV["BUNDLE_FOO"] = "foo_val"
bundle! "config get foo --parseable"
- expect(last_command.stdout).to eq "foo=foo_val"
+ expect(out).to eq "foo=foo_val"
bundle! "config get foo"
- expect(last_command.stdout).to eq "Settings for `foo` in order of priority. The top value will be used\nSet via BUNDLE_FOO: \"foo_val\""
+ expect(out).to eq "Settings for `foo` in order of priority. The top value will be used\nSet via BUNDLE_FOO: \"foo_val\""
end
it "set" do
bundle! "config set foo 1"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
bundle! "config set --local foo 2"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
bundle! "config set --global foo 3"
- expect(last_command.stdout).to eq "Your application has set foo to \"2\". This will override the global value you are currently setting"
+ expect(out).to eq "Your application has set foo to \"2\". This will override the global value you are currently setting"
bundle! "config set --parseable --local foo 4"
- expect(last_command.stdout).to eq "foo=4"
+ expect(out).to eq "foo=4"
bundle! "config set --local foo 4.1"
- expect(last_command.stdout).to eq "You are replacing the current local value of foo, which is currently \"4\""
+ expect(out).to eq "You are replacing the current local value of foo, which is currently \"4\""
bundle "config set --global --local foo 5"
expect(last_command).to be_failure
- expect(last_command.bundler_err).to eq "The options global and local were specified. Please only use one of the switches at a time."
+ expect(err).to eq "The options global and local were specified. Please only use one of the switches at a time."
end
it "unset" do
bundle! "config unset foo"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
bundle! "config set foo 1"
bundle! "config unset foo --parseable"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
bundle! "config set --local foo 1"
bundle! "config set --global foo 2"
bundle! "config unset foo"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
bundle! "config set --local foo 1"
bundle! "config set --global foo 2"
bundle! "config unset foo --local"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for the current user (#{home(".bundle/config")}): \"2\""
bundle! "config unset foo --global"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
bundle! "config set --local foo 1"
bundle! "config set --global foo 2"
bundle! "config unset foo --global"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for your local app (#{bundled_app(".bundle/config")}): \"1\""
bundle! "config unset foo --local"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
bundle "config unset foo --local --global"
expect(last_command).to be_failure
- expect(last_command.bundler_err).to eq "The options global and local were specified. Please only use one of the switches at a time."
+ expect(err).to eq "The options global and local were specified. Please only use one of the switches at a time."
end
end
end
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index a95383ee97..655313534d 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -88,14 +88,14 @@ RSpec.describe "bundle exec" do
sys_exec "#{Gem.ruby} #{command.path}"
expect(out).to eq("")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "accepts --keep-file-descriptors" do
install_gemfile ""
bundle "exec --keep-file-descriptors echo foobar"
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "can run a command named --verbose" do
@@ -156,7 +156,7 @@ RSpec.describe "bundle exec" do
bundle! "exec irb --version"
expect(out).to include(default_irb_version)
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
@@ -182,7 +182,7 @@ RSpec.describe "bundle exec" do
bundle! "exec irb --version"
expect(out).to include(specified_irb_version)
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
@@ -212,7 +212,7 @@ RSpec.describe "bundle exec" do
it "uses resolved version" do
expect(out).to include(indirect_irb_version)
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
end
@@ -334,7 +334,7 @@ RSpec.describe "bundle exec" do
[true, false].each do |l|
bundle! "config set disable_exec_load #{l}"
bundle "exec rackup"
- expect(last_command.stderr).to include "can't find executable rackup for gem rack. rack is not currently included in the bundle, perhaps you meant to add it to your Gemfile?"
+ expect(err).to include "can't find executable rackup for gem rack. rack is not currently included in the bundle, perhaps you meant to add it to your Gemfile?"
end
end
@@ -552,8 +552,8 @@ RSpec.describe "bundle exec" do
bundle "exec irb"
- expect(last_command.stderr).to match("The gemspec at #{lib_path("foo-1.0").join("foo.gemspec")} is not valid")
- expect(last_command.stderr).to match('"TODO" is not a summary')
+ expect(err).to match("The gemspec at #{lib_path("foo-1.0").join("foo.gemspec")} is not valid")
+ expect(err).to match('"TODO" is not a summary')
end
end
@@ -614,8 +614,8 @@ RSpec.describe "bundle exec" do
it "like a normally executed executable" do
subject
expect(exitstatus).to eq(exit_code) if exitstatus
- expect(last_command.stderr).to eq(expected_err)
- expect(last_command.stdout).to eq(expected)
+ expect(err).to eq(expected_err)
+ expect(out).to eq(expected)
end
end
@@ -886,7 +886,7 @@ __FILE__: #{path.to_s.inspect}
# sanity check that we get the newer, custom version without bundler
sys_exec("#{Gem.ruby} #{file}")
- expect(last_command.stderr).to include("custom openssl should not be loaded")
+ expect(err).to include("custom openssl should not be loaded")
end
end
end
diff --git a/spec/commands/init_spec.rb b/spec/commands/init_spec.rb
index 64849beeb9..7960ce85bd 100644
--- a/spec/commands/init_spec.rb
+++ b/spec/commands/init_spec.rb
@@ -94,7 +94,7 @@ RSpec.describe "bundle init" do
end
bundle :init, :gemspec => spec_file
- expect(last_command.bundler_err).to include("There was an error while loading `test.gemspec`")
+ expect(err).to include("There was an error while loading `test.gemspec`")
end
end
end
diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb
index 21157dd309..1a027a77c9 100644
--- a/spec/commands/install_spec.rb
+++ b/spec/commands/install_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe "bundle install with gem sources" do
raise StandardError, "FAIL"
G
- expect(last_command.bundler_err).to include('StandardError, "FAIL"')
+ expect(err).to include('StandardError, "FAIL"')
expect(bundled_app("Gemfile.lock")).not_to exist
end
@@ -404,7 +404,7 @@ RSpec.describe "bundle install with gem sources" do
G
expect(last_command.stdboth).not_to match(/Error Report/i)
- expect(last_command.bundler_err).to include("An error occurred while installing ajp-rails (0.0.0), and Bundler cannot continue.").
+ expect(err).to include("An error occurred while installing ajp-rails (0.0.0), and Bundler cannot continue.").
and include(normalize_uri_file("Make sure that `gem install ajp-rails -v '0.0.0' --source 'file://localhost#{gem_repo2}/'` succeeds before bundling."))
end
diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb
index f876d719cc..7aaf5c178e 100644
--- a/spec/commands/lock_spec.rb
+++ b/spec/commands/lock_spec.rb
@@ -242,7 +242,7 @@ RSpec.describe "bundle lock" do
it "errors when removing all platforms" do
bundle "lock --remove-platform #{local_platforms.join(" ")}"
- expect(last_command.bundler_err).to include("Removing all platforms from the bundle is not allowed")
+ expect(err).to include("Removing all platforms from the bundle is not allowed")
end
# from https://github.com/bundler/bundler/issues/4896
diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb
index 0d1058ad11..bb04f33c80 100644
--- a/spec/commands/newgem_spec.rb
+++ b/spec/commands/newgem_spec.rb
@@ -770,22 +770,22 @@ RSpec.describe "bundle gem" do
it "fails gracefully with a ." do
bundle "gem foo.gemspec"
- expect(last_command.bundler_err).to end_with("Invalid gem name foo.gemspec -- `Foo.gemspec` is an invalid constant name")
+ expect(err).to end_with("Invalid gem name foo.gemspec -- `Foo.gemspec` is an invalid constant name")
end
it "fails gracefully with a ^" do
bundle "gem ^"
- expect(last_command.bundler_err).to end_with("Invalid gem name ^ -- `^` is an invalid constant name")
+ expect(err).to end_with("Invalid gem name ^ -- `^` is an invalid constant name")
end
it "fails gracefully with a space" do
bundle "gem 'foo bar'"
- expect(last_command.bundler_err).to end_with("Invalid gem name foo bar -- `Foo bar` is an invalid constant name")
+ expect(err).to end_with("Invalid gem name foo bar -- `Foo bar` is an invalid constant name")
end
it "fails gracefully when multiple names are passed" do
bundle "gem foo bar baz"
- expect(last_command.bundler_err).to eq(<<-E.strip)
+ expect(err).to eq(<<-E.strip)
ERROR: "bundle gem" was called with arguments ["foo", "bar", "baz"]
Usage: "bundle gem NAME [OPTIONS]"
E
@@ -876,7 +876,7 @@ Usage: "bundle gem NAME [OPTIONS]"
FileUtils.touch("conflict-foobar")
end
bundle "gem conflict-foobar"
- expect(last_command.bundler_err).to include("Errno::ENOTDIR")
+ expect(err).to include("Errno::ENOTDIR")
expect(exitstatus).to eql(32) if exitstatus
end
end
@@ -887,7 +887,7 @@ Usage: "bundle gem NAME [OPTIONS]"
FileUtils.mkdir_p("conflict-foobar/Gemfile")
end
bundle! "gem conflict-foobar"
- expect(last_command.stdout).to include("file_clash conflict-foobar/Gemfile").
+ expect(out).to include("file_clash conflict-foobar/Gemfile").
and include "Initializing git repo in #{bundled_app("conflict-foobar")}"
end
end
diff --git a/spec/commands/package_spec.rb b/spec/commands/package_spec.rb
index 6cd8e3f85a..b9cc079c5c 100644
--- a/spec/commands/package_spec.rb
+++ b/spec/commands/package_spec.rb
@@ -278,7 +278,7 @@ RSpec.describe "bundle install with gem sources" do
end
bundle :install
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(the_bundle).to include_gems "rack 1.0"
end
diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb
index 46c208db6c..d78ee26c1f 100644
--- a/spec/commands/update_spec.rb
+++ b/spec/commands/update_spec.rb
@@ -565,13 +565,13 @@ RSpec.describe "bundle update when a gem depends on a newer version of bundler"
it "should explain that bundler conflicted", :bundler => "< 3" do
bundle "update", :all => true
expect(last_command.stdboth).not_to match(/in snapshot/i)
- expect(last_command.bundler_err).to match(/current Bundler version/i).
+ expect(err).to match(/current Bundler version/i).
and match(/perhaps you need to update bundler/i)
end
it "should warn that the newer version of Bundler would conflict", :bundler => "3" do
bundle! "update", :all => true
- expect(last_command.bundler_err).to include("rails (3.0.1) has dependency bundler").
+ expect(err).to include("rails (3.0.1) has dependency bundler").
and include("so the dependency is being ignored")
expect(the_bundle).to include_gem "rails 3.0.1"
end
@@ -947,7 +947,7 @@ RSpec.describe "bundle update conservative" do
it "raises if too many flags are provided" do
bundle "update --patch --minor", :all => true
- expect(last_command.bundler_err).to eq "Provide only one of the following options: minor, patch"
+ expect(err).to eq "Provide only one of the following options: minor, patch"
end
end
end