summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-12-12 12:09:52 +0000
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-12-13 20:07:21 +0100
commit4e5e9cd49b16f136482505de6a3258aabdb26a99 (patch)
treeb0b691eb55d624f1d714b9eaed8a6e2265e8c82e /spec
parentcd3fb55c06b18673f2cfbb946d6fc81375afa3ea (diff)
downloadbundler-4e5e9cd49b16f136482505de6a3258aabdb26a99.tar.gz
Merge #7474
7474: Fix `bundle exec rake install` failing r=deivid-rodriguez a=deivid-rodriguez ### What was the end-user problem that led to this PR? The problem was that I noticed `bundle exec rake install` was failing on my gem using the latest prerelease of bundler. ### What was your diagnosis of the problem? My diagnosis was that `bundler` silences output of rubygems by default, and in a `bundle exec` context, `bundler/setup` is always required by subprocesses. So, the `rake install` task is silencing rubygems, but it requires it to not be silent: https://github.com/bundler/bundler/blob/bada03dd6d4d15828fb5b2cf7f744948e88a69a3/lib/bundler/gem_helper.rb#L91-L92 ### What is your fix for the problem, implemented in this PR? My fix is to wrap the execution of the rubygems subprocess with `Bundler.with_original_env` so that the `gem` command runs without `bundler` involved. Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net> (cherry picked from commit f44ebf017001239a3e66589dff5aa77f631ca6e2)
Diffstat (limited to 'spec')
-rw-r--r--spec/commands/clean_spec.rb2
-rw-r--r--spec/commands/exec_spec.rb2
-rw-r--r--spec/commands/outdated_spec.rb2
-rw-r--r--spec/runtime/gem_tasks_spec.rb24
-rw-r--r--spec/runtime/setup_spec.rb12
-rw-r--r--spec/support/path.rb2
6 files changed, 33 insertions, 11 deletions
diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb
index 7f9f84c104..5cc97de912 100644
--- a/spec/commands/clean_spec.rb
+++ b/spec/commands/clean_spec.rb
@@ -782,7 +782,7 @@ RSpec.describe "bundle clean" do
expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist
bundle! :clean
- expect(out).to eq("")
+ expect(out).to be_empty
expect(vendored_gems("bundler/gems/extensions")).to exist
expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index d2e85a289b..a5d67c6d68 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -104,7 +104,7 @@ RSpec.describe "bundle exec" do
install_gemfile ""
sys_exec "#{Gem.ruby} #{command.path}"
- expect(out).to eq("")
+ expect(out).to be_empty
expect(err).to be_empty
end
diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb
index ab54925756..6e82d34b05 100644
--- a/spec/commands/outdated_spec.rb
+++ b/spec/commands/outdated_spec.rb
@@ -228,7 +228,7 @@ RSpec.describe "bundle outdated" do
context "and no gems are outdated" do
it "has empty output" do
subject
- expect(out).to eq("")
+ expect(out).to be_empty
end
end
end
diff --git a/spec/runtime/gem_tasks_spec.rb b/spec/runtime/gem_tasks_spec.rb
index 4760b6a749..4b92de76bb 100644
--- a/spec/runtime/gem_tasks_spec.rb
+++ b/spec/runtime/gem_tasks_spec.rb
@@ -6,15 +6,25 @@ RSpec.describe "require 'bundler/gem_tasks'" do
f.write <<-GEMSPEC
Gem::Specification.new do |s|
s.name = "foo"
+ s.version = "1.0"
+ s.summary = "dummy"
+ s.author = "Perry Mason"
end
GEMSPEC
end
+
bundled_app("Rakefile").open("w") do |f|
f.write <<-RAKEFILE
$:.unshift("#{lib_dir}")
require "bundler/gem_tasks"
RAKEFILE
end
+
+ install_gemfile! <<-G
+ source "#{file_uri_for(gem_repo1)}"
+
+ gem "rake"
+ G
end
it "includes the relevant tasks" do
@@ -22,7 +32,7 @@ RSpec.describe "require 'bundler/gem_tasks'" do
sys_exec "#{rake} -T", "RUBYOPT" => "-I#{lib_dir}"
end
- expect(err).to eq("")
+ expect(err).to be_empty
expected_tasks = [
"rake build",
"rake clean",
@@ -35,6 +45,18 @@ RSpec.describe "require 'bundler/gem_tasks'" do
expect(exitstatus).to eq(0) if exitstatus
end
+ it "defines a working `rake install` task" do
+ with_gem_path_as(Spec::Path.base_system_gems.to_s) do
+ sys_exec "#{rake} install", "RUBYOPT" => "-I#{lib_dir}"
+ end
+
+ expect(err).to be_empty
+
+ bundle! "exec rake install"
+
+ expect(err).to be_empty
+ end
+
it "adds 'pkg' to rake/clean's CLOBBER" do
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
sys_exec! %(#{rake} -e 'load "Rakefile"; puts CLOBBER.inspect')
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index 80c38e9f4a..8769b00426 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -130,7 +130,7 @@ RSpec.describe "Bundler.setup" do
load_path = out.split("\n")
rack_load_order = load_path.index {|path| path.include?("rack") }
- expect(err).to eq("")
+ expect(err).to be_empty
expect(load_path).to include(a_string_ending_with("dash_i_dir"), "rubylib_dir")
expect(rack_load_order).to be > 0
end
@@ -1042,7 +1042,7 @@ end
RUBY
expect(err).to be_empty
- expect(out).to eq("")
+ expect(out).to be_empty
end
end
@@ -1098,8 +1098,8 @@ end
it "does not change the lock or warn" do
lockfile lock_with(Bundler::VERSION.succ)
ruby "require '#{lib_dir}/bundler/setup'"
- expect(out).to eq("")
- expect(err).to eq("")
+ expect(out).to be_empty
+ expect(err).to be_empty
lockfile_should_be lock_with(Bundler::VERSION.succ)
end
end
@@ -1162,8 +1162,8 @@ end
let(:ruby_version) { "5.5.5" }
it "does not change the lock or warn" do
expect { ruby! "require '#{lib_dir}/bundler/setup'" }.not_to change { lockfile }
- expect(out).to eq("")
- expect(err).to eq("")
+ expect(out).to be_empty
+ expect(err).to be_empty
end
end
diff --git a/spec/support/path.rb b/spec/support/path.rb
index 3e42589f4d..1c142e2643 100644
--- a/spec/support/path.rb
+++ b/spec/support/path.rb
@@ -22,7 +22,7 @@ module Spec
end
def gem_bin
- @gem_bin ||= ruby_core? ? ENV["GEM_COMMAND"] : "#{Gem.ruby} -I#{spec_dir}/rubygems -S gem --backtrace"
+ @gem_bin ||= ruby_core? ? ENV["GEM_COMMAND"] : "#{Gem.ruby} -S gem --backtrace"
end
def spec_dir