diff options
Diffstat (limited to 'spec/bundler/runtime/setup_spec.rb')
-rw-r--r-- | spec/bundler/runtime/setup_spec.rb | 91 |
1 files changed, 57 insertions, 34 deletions
diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb index ead826c4e6..da1a2ae6e2 100644 --- a/spec/bundler/runtime/setup_spec.rb +++ b/spec/bundler/runtime/setup_spec.rb @@ -12,7 +12,7 @@ RSpec.describe "Bundler.setup" do G ruby <<-RUBY - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup require 'rack' @@ -34,7 +34,7 @@ RSpec.describe "Bundler.setup" do it "doesn't make all groups available" do ruby <<-RUBY - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup(:default) begin @@ -49,7 +49,7 @@ RSpec.describe "Bundler.setup" do it "accepts string for group name" do ruby <<-RUBY - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup(:default, 'test') require 'rack' @@ -61,7 +61,7 @@ RSpec.describe "Bundler.setup" do it "leaves all groups available if they were already" do ruby <<-RUBY - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup Bundler.setup(:default) @@ -74,7 +74,7 @@ RSpec.describe "Bundler.setup" do it "leaves :default available if setup is called twice" do ruby <<-RUBY - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup(:default) Bundler.setup(:default, :test) @@ -91,7 +91,7 @@ RSpec.describe "Bundler.setup" do it "handles multiple non-additive invocations" do ruby <<-RUBY, :raise_on_error => false - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup(:default, :test) Bundler.setup(:default) require 'rack' @@ -122,7 +122,7 @@ RSpec.describe "Bundler.setup" do ENV["RUBYLIB"] = "rubylib_dir" ruby <<-RUBY - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup puts $LOAD_PATH RUBY @@ -143,6 +143,10 @@ RSpec.describe "Bundler.setup" do gem "rails" G + # We require an absolute path because relying on the $LOAD_PATH behaves + # inconsistently depending on whether we're in a ruby-core setup (and + # bundler's lib is in RUBYLIB) or not. + ruby <<-RUBY require '#{lib_dir}/bundler' Bundler.setup @@ -171,6 +175,10 @@ RSpec.describe "Bundler.setup" do gem "terranova" G + # We require an absolute path because relying on the $LOAD_PATH behaves + # inconsistently depending on whether we're in a ruby-core setup (and + # bundler's lib is in RUBYLIB) or not. + ruby <<-RUBY require '#{lib_dir}/bundler/setup' puts $LOAD_PATH @@ -192,8 +200,10 @@ RSpec.describe "Bundler.setup" do gem "rack" G + entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler" : "bundler" + ruby <<-R - require '#{lib_dir}/bundler' + require '#{entrypoint}' begin Bundler.setup @@ -213,7 +223,7 @@ RSpec.describe "Bundler.setup" do G ruby <<-R, :raise_on_error => false - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup R @@ -236,7 +246,7 @@ RSpec.describe "Bundler.setup" do G ruby <<-R, :raise_on_error => false - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup R @@ -289,7 +299,7 @@ RSpec.describe "Bundler.setup" do ENV["BUNDLE_GEMFILE"] = "Gemfile" ruby <<-R - require '#{lib_dir}/bundler' + require 'bundler' begin Bundler.setup @@ -444,7 +454,7 @@ RSpec.describe "Bundler.setup" do break_git! ruby <<-R - require '#{lib_dir}/bundler' + require 'bundler' begin Bundler.setup @@ -464,8 +474,10 @@ RSpec.describe "Bundler.setup" do break_git! + entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler" : "bundler" + ruby <<-R - require "#{lib_dir}/bundler" + require "#{entrypoint}" begin Bundler.setup @@ -481,14 +493,14 @@ RSpec.describe "Bundler.setup" do end it "works even when the cache directory has been deleted" do - bundle "config --local path vendor/bundle" + bundle "config set --local path vendor/bundle" bundle :install FileUtils.rm_rf vendored_gems("cache") expect(the_bundle).to include_gems "rack 1.0.0" end it "does not randomly change the path when specifying --path and the bundle directory becomes read only" do - bundle "config --local path vendor/bundle" + bundle "config set --local path vendor/bundle" bundle :install with_read_only("#{bundled_app}/**/*") do @@ -592,7 +604,7 @@ RSpec.describe "Bundler.setup" do describe "when excluding groups" do it "doesn't change the resolve if --without is used" do - bundle "config --local without rails" + bundle "config set --local without rails" install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "activesupport" @@ -608,7 +620,7 @@ RSpec.describe "Bundler.setup" do end it "remembers --without and does not bail on bare Bundler.setup" do - bundle "config --local without rails" + bundle "config set --local without rails" install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "activesupport" @@ -624,7 +636,7 @@ RSpec.describe "Bundler.setup" do end it "remembers --without and does not bail on bare Bundler.setup, even in the case of path gems no longer available" do - bundle "config --local without development" + bundle "config set --local without development" path = bundled_app(File.join("vendor", "foo")) build_lib "foo", :path => path @@ -644,7 +656,7 @@ RSpec.describe "Bundler.setup" do end it "remembers --without and does not include groups passed to Bundler.setup" do - bundle "config --local without rails" + bundle "config set --local without rails" install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "activesupport" @@ -798,7 +810,7 @@ end # Don't build extensions. s.class.send(:define_method, :build_extensions) { nil } - require '#{lib_dir}/bundler' + require 'bundler' gem '#{gem_name}' puts $LOAD_PATH.count {|path| path =~ /#{gem_name}/} >= 2 @@ -1056,7 +1068,7 @@ end bundle "install" ruby <<-RUBY - require '#{lib_dir}/bundler' + require 'bundler' bundler_module = class << Bundler; self; end bundler_module.send(:remove_method, :require) def Bundler.require(path) @@ -1104,6 +1116,8 @@ end end before do + bundle "config set --local path.system true" + install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -1112,8 +1126,9 @@ end context "is not present" do it "does not change the lock" do + entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler/setup" : "bundler/setup" lockfile lock_with(nil) - ruby "require '#{lib_dir}/bundler/setup'" + ruby "require '#{entrypoint}'" lockfile_should_be lock_with(nil) end end @@ -1121,7 +1136,7 @@ end context "is newer" do it "does not change the lock or warn" do lockfile lock_with(Bundler::VERSION.succ) - ruby "require '#{lib_dir}/bundler/setup'" + ruby "require 'bundler/setup'" expect(out).to be_empty expect(err).to be_empty lockfile_should_be lock_with(Bundler::VERSION.succ) @@ -1130,8 +1145,10 @@ end context "is older" do it "does not change the lock" do + entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler/setup" : "bundler/setup" + system_gems "bundler-1.10.1" lockfile lock_with("1.10.1") - ruby "require '#{lib_dir}/bundler/setup'" + ruby "require '#{entrypoint}'" lockfile_should_be lock_with("1.10.1") end end @@ -1178,14 +1195,14 @@ end context "is not present" do it "does not change the lock" do - expect { ruby "require '#{lib_dir}/bundler/setup'" }.not_to change { lockfile } + expect { ruby "require 'bundler/setup'" }.not_to change { lockfile } end end context "is newer" do 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 { ruby "require 'bundler/setup'" }.not_to change { lockfile } expect(out).to be_empty expect(err).to be_empty end @@ -1194,7 +1211,7 @@ end context "is older" do let(:ruby_version) { "1.0.0" } it "does not change the lock" do - expect { ruby "require '#{lib_dir}/bundler/setup'" }.not_to change { lockfile } + expect { ruby "require 'bundler/setup'" }.not_to change { lockfile } end end end @@ -1202,8 +1219,9 @@ end describe "with gemified standard libraries" do it "does not load Psych" do gemfile "" + entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler/setup" : "bundler/setup" ruby <<-RUBY - require '#{lib_dir}/bundler/setup' + require '#{entrypoint}' puts defined?(Psych::VERSION) ? Psych::VERSION : "undefined" require 'psych' puts Psych::VERSION @@ -1216,7 +1234,7 @@ end it "does not load openssl" do install_gemfile "" ruby <<-RUBY - require "#{lib_dir}/bundler/setup" + require "bundler/setup" puts defined?(OpenSSL) || "undefined" require "openssl" puts defined?(OpenSSL) || "undefined" @@ -1274,7 +1292,7 @@ end it "activates no gems with -rbundler/setup" do install_gemfile "" - ruby code, :env => { "RUBYOPT" => activation_warning_hack_rubyopt + " -r#{lib_dir}/bundler/setup" } + ruby code, :env => { "RUBYOPT" => activation_warning_hack_rubyopt + " -rbundler/setup" } expect(out).to eq("{}") end @@ -1327,7 +1345,7 @@ end if File.exist?(ext_folder.join("#{require_name}.rb")) { :exclude_from_load_path => ext_folder.to_s } else - lib_folder = source_root.join("lib") + lib_folder = source_lib_dir if File.exist?(lib_folder.join("#{require_name}.rb")) { :exclude_from_load_path => lib_folder.to_s } else @@ -1383,7 +1401,7 @@ end G ruby <<-RUBY - require "#{lib_dir}/bundler/setup" + require "bundler/setup" Object.new.gem "rack" puts Gem.loaded_specs["rack"].full_name RUBY @@ -1398,7 +1416,7 @@ end G ruby <<-RUBY, :raise_on_error => false - require "#{lib_dir}/bundler/setup" + require "bundler/setup" Object.new.gem "rack" puts "FAIL" RUBY @@ -1414,7 +1432,7 @@ end G ruby <<-RUBY, :raise_on_error => false - require "#{lib_dir}/bundler/setup" + require "bundler/setup" Object.new.require "rack" puts "FAIL" RUBY @@ -1429,4 +1447,9 @@ end expect(last_command.stdboth).to eq("true") end end + + # Tested rubygems does not include https://github.com/rubygems/rubygems/pull/2728 and will not always end up activating the current bundler + def mis_activates_prerelease_default_bundler? + Gem.rubygems_version < Gem::Version.new("3.1.a") + end end |