From ee689f171060ee35f0ea863ef03f19a3a5b2c545 Mon Sep 17 00:00:00 2001 From: Hsing-Hui Hsu Date: Wed, 3 Feb 2016 10:07:41 -0800 Subject: Address feedback on spec. - Use real -I and RUBYLIB variable setting - Use Array#index to find path for loaded gem --- spec/runtime/setup_spec.rb | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'spec/runtime') diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 453e9603..65a310e7 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -108,29 +108,36 @@ describe "Bundler.setup" do end end - it "puts loaded gems after -I and RUBYLIB" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - G + context "load order" do + after do + ENV.delete "RUBYLIB" + ENV.delete "RUBYOPT" + end - ruby <<-RUBY - require 'rubygems' - require 'bundler' - $LOAD_PATH.unshift('fake -I') - Bundler.setup + it "puts loaded gems after -I and RUBYLIB" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G - puts $LOAD_PATH - RUBY + ENV["RUBYOPT"] = "-I dash_i_dir" + ENV["RUBYLIB"] = "rubylib_dir" - load_path = out.split("\n") - rack_load_order = load_path.each_with_index do |dir, i| - break i if dir =~ /rack/ - end + ruby <<-RUBY + require 'rubygems' + require 'bundler' + Bundler.setup + puts $LOAD_PATH + RUBY + + load_path = out.split("\n") + rack_load_order = load_path.index {|path| path.include?("rack") } - expect(err).to eq("") - expect(load_path.first).to eq("fake -I") - expect(rack_load_order).to be > 0 + expect(err).to eq("") + expect(load_path[1]).to include "dash_i_dir" + expect(load_path[2]).to include "rubylib_dir" + expect(rack_load_order).to be > 0 + end end it "raises if the Gemfile was not yet installed" do -- cgit v1.2.3