Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Remove unnecessary rubygems monkeypatch
Browse files Browse the repository at this point in the history
Instead, make sure we always load the local copy of bundler during
specs, and never end up using the default copy.
  • Loading branch information
deivid-rodriguez committed Aug 3, 2019
1 parent 5df7427 commit 9e135d4
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 61 deletions.
2 changes: 1 addition & 1 deletion lib/bundler.rb
Expand Up @@ -299,7 +299,7 @@ def unbundled_env
env.delete_if {|k, _| k[0, 7] == "BUNDLE_" }

if env.key?("RUBYOPT")
env["RUBYOPT"] = env["RUBYOPT"].sub "-rbundler/setup", ""
env["RUBYOPT"] = env["RUBYOPT"].sub "-r#{File.expand_path("bundler/setup", __dir__)}", ""
end

if env.key?("RUBYLIB")
Expand Down
3 changes: 1 addition & 2 deletions spec/commands/pristine_spec.rb
Expand Up @@ -42,8 +42,7 @@
expect(changes_txt).to_not be_file
end

it "does not delete the bundler gem", :rubygems => ">= 2.6.2" do
ENV["BUNDLER_SPEC_KEEP_DEFAULT_BUNDLER_GEM"] = "true"
it "does not delete the bundler gem" do
system_gems :bundler
bundle! "install"
bundle! "pristine", :system_bundler => true
Expand Down
2 changes: 1 addition & 1 deletion spec/install/gemfile/groups_spec.rb
Expand Up @@ -333,7 +333,7 @@
G

ruby <<-R
require "bundler"
require "#{__dir__}/../../../lib/bundler"
Bundler.setup :default
Bundler.require :default
puts RACK
Expand Down
2 changes: 2 additions & 0 deletions spec/install/gems/compact_index_spec.rb
Expand Up @@ -528,6 +528,8 @@ def require(*args)
gem "rack"
G

system_gems :bundler

bundle "install --binstubs", :artifice => "compact_index"

gembin "rackup"
Expand Down
2 changes: 2 additions & 0 deletions spec/install/gems/dependency_api_spec.rb
Expand Up @@ -502,6 +502,8 @@ def require(*args)
gem "rack"
G

system_gems :bundler

bundle "install --binstubs", :artifice => "endpoint"

gembin "rackup"
Expand Down
1 change: 0 additions & 1 deletion spec/plugins/source/example_spec.rb
Expand Up @@ -6,7 +6,6 @@
build_repo2 do
build_plugin "bundler-source-mpath" do |s|
s.write "plugins.rb", <<-RUBY
require "bundler/vendored_fileutils"
require "bundler-source-mpath"
class MPath < Bundler::Plugin::API
Expand Down
4 changes: 2 additions & 2 deletions spec/realworld/double_check_spec.rb
Expand Up @@ -25,9 +25,9 @@
RUBY

cmd = <<-RUBY
require "bundler"
require #{File.expand_path("../../../lib/bundler.rb", __FILE__).dump}
require #{File.expand_path("../../support/artifice/vcr.rb", __FILE__).dump}
require "bundler/inline"
require #{File.expand_path("../../../lib/bundler/inline.rb", __FILE__).dump}
gemfile(true) do
source "https://rubygems.org"
gem "rails", path: "."
Expand Down
20 changes: 10 additions & 10 deletions spec/runtime/executable_spec.rb
Expand Up @@ -9,7 +9,7 @@
end

it "runs the bundled command when in the bundle" do
bundle! "binstubs rack"
bundle! "binstubs rack bundler"

build_gem "rack", "2.0", :to_system => true do |s|
s.executables = "rackup"
Expand All @@ -20,7 +20,7 @@
end

it "allows the location of the gem stubs to be specified" do
bundle! "binstubs rack", :path => "gbin"
bundle! "binstubs rack bundler", :path => "gbin"

expect(bundled_app("bin")).not_to exist
expect(bundled_app("gbin/rackup")).to exist
Expand All @@ -30,19 +30,19 @@
end

it "allows absolute paths as a specification of where to install bin stubs" do
bundle! "binstubs rack", :path => tmp("bin")
bundle! "binstubs rack bundler", :path => tmp("bin")

gembin tmp("bin/rackup")
expect(out).to eq("1.0.0")
end

it "uses the default ruby install name when shebang is not specified" do
bundle! "binstubs rack"
bundle! "binstubs rack bundler"
expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env #{RbConfig::CONFIG["ruby_install_name"]}\n")
end

it "allows the name of the shebang executable to be specified" do
bundle! "binstubs rack", :shebang => "ruby-foo"
bundle! "binstubs rack bundler", :shebang => "ruby-foo"
expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env ruby-foo\n")
end

Expand All @@ -69,7 +69,7 @@
gem "rack", :path => "#{lib_path("rack")}"
G

bundle! "binstubs rack"
bundle! "binstubs rack bundler"

build_gem "rack", "2.0", :to_system => true do |s|
s.executables = "rackup"
Expand Down Expand Up @@ -138,7 +138,7 @@

create_file("bin/rackup", "OMG")

bundle! "binstubs rack"
bundle! "binstubs rack bundler"

expect(bundled_app("bin/rackup").read).to_not eq("OMG")
end
Expand All @@ -162,12 +162,12 @@
bundle "install"
bundle! "binstubs bindir"

# remove user settings
ENV["BUNDLE_GEMFILE"] = nil

# run binstub for non default Gemfile
gembin "foo"

# remove user settings
ENV["BUNDLE_GEMFILE"] = nil

expect(exitstatus).to eq(0) if exitstatus
expect(out).to eq("1.0")
end
Expand Down
6 changes: 3 additions & 3 deletions spec/runtime/inline_spec.rb
Expand Up @@ -2,7 +2,7 @@

RSpec.describe "bundler/inline#gemfile" do
def script(code, options = {})
requires = ["bundler/inline"]
requires = ["../../lib/bundler/inline.rb"]
requires.unshift File.expand_path("../../support/artifice/" + options.delete(:artifice) + ".rb", __FILE__) if options.key?(:artifice)
requires = requires.map {|r| "require '#{r}'" }.join("\n")
@out = ruby("#{requires}\n\n" + code, options)
Expand Down Expand Up @@ -96,7 +96,7 @@ def script(code, options = {})

it "lets me use my own ui object" do
script <<-RUBY, :artifice => "endpoint"
require 'bundler'
require '../../lib/bundler'
class MyBundlerUI < Bundler::UI::Silent
def confirm(msg, newline = nil)
puts "CONFIRMED!"
Expand Down Expand Up @@ -140,7 +140,7 @@ def confirm(msg, newline = nil)

it "does not mutate the option argument" do
script <<-RUBY
require 'bundler'
require '../../lib/bundler'
options = { :ui => Bundler::UI::Shell.new }
gemfile(false, options) do
path "#{lib_path}" do
Expand Down
2 changes: 1 addition & 1 deletion spec/runtime/load_spec.rb
Expand Up @@ -80,7 +80,7 @@
G

ruby! <<-RUBY
require "bundler"
require "../../lib/bundler"
Bundler.setup :default
Bundler.require :default
puts RACK
Expand Down
2 changes: 1 addition & 1 deletion spec/runtime/require_spec.rb
Expand Up @@ -193,7 +193,7 @@
G

cmd = <<-RUBY
require 'bundler'
require '../../lib/bundler'
Bundler.require
RUBY
ruby(cmd)
Expand Down

0 comments on commit 9e135d4

Please sign in to comment.