diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-06-06 15:49:17 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-06-06 15:49:17 -0500 |
commit | 81656610125de15a56834a91ff4f8608b1dc04cc (patch) | |
tree | 16be450a5fc1959225c5112fa87fb2c820875c15 | |
parent | 0c8cbfd4a186bf37d65a113bc16655013657af56 (diff) | |
download | bundler-81656610125de15a56834a91ff4f8608b1dc04cc.tar.gz |
Add a spec for sorting loaded specs by name on the $LOAD_PATHseg-sort-by-name-spec-set
-rw-r--r-- | spec/runtime/setup_spec.rb | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index c94147dff7..8418f63c3b 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -108,6 +108,17 @@ RSpec.describe "Bundler.setup" do end context "load order" do + def clean_load_path(lp) + without_bundler_load_path = ruby!("puts $LOAD_PATH").split("\n") + lp = lp - [ + bundler_path.to_s, + bundler_path.join("gems/bundler-#{Bundler::VERSION}/lib").to_s, + tmp("rubygems/lib").to_s, + root.join("../lib").expand_path.to_s, + ] - without_bundler_load_path + lp.map! {|p| p.sub(/^#{system_gem_path}/, "") } + end + it "puts loaded gems after -I and RUBYLIB" do install_gemfile <<-G source "file://#{gem_repo1}" @@ -139,8 +150,6 @@ RSpec.describe "Bundler.setup" do gem "rails" G - without_bundler_load_path = ruby!("puts $LOAD_PATH").split("\n") - ruby! <<-RUBY require 'rubygems' require 'bundler' @@ -148,13 +157,7 @@ RSpec.describe "Bundler.setup" do puts $LOAD_PATH RUBY - load_path = out.split("\n") - [ - bundler_path.to_s, - bundler_path.join("gems/bundler-#{Bundler::VERSION}/lib").to_s, - tmp("rubygems/lib").to_s, - root.join("../lib").expand_path.to_s, - ] - without_bundler_load_path - load_path.map! {|lp| lp.sub(/^#{system_gem_path}/, "") } + load_path = clean_load_path(out.split("\n")) expect(load_path).to start_with( "/gems/rails-2.3.2/lib", @@ -166,6 +169,29 @@ RSpec.describe "Bundler.setup" do "/gems/rake-10.0.2/lib" ) end + + it "falls back to order the load path alphabetically for backwards compatibility" do + install_gemfile! <<-G + source "file://#{gem_repo1}" + gem "weakling" + gem "duradura" + gem "terranova" + G + + ruby! <<-RUBY + require 'rubygems' + require 'bundler/setup' + puts $LOAD_PATH + RUBY + + load_path = clean_load_path(out.split("\n")) + + expect(load_path).to start_with( + "/gems/weakling-0.0.3/lib", + "/gems/terranova-8/lib", + "/gems/duradura-7.0/lib" + ) + end end it "raises if the Gemfile was not yet installed" do |