diff options
author | Homu <homu@barosl.com> | 2016-05-21 06:16:25 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-05-21 06:16:25 +0900 |
commit | 7351eddd5b70f1fa707404386f2afe34a6127cf0 (patch) | |
tree | dcf4c169bf4f3fca6b1dc20de2f446d778abb7a5 | |
parent | 112272e0c69213e816772b2e39a7f76334502cb8 (diff) | |
parent | b1d5c7d8469b07554c0e64c54c3995fb56136859 (diff) | |
download | bundler-7351eddd5b70f1fa707404386f2afe34a6127cf0.tar.gz |
Auto merge of #4585 - RochesterinNYC:eval-gemfile-expanded-pathing, r=segiddins
Use the full expanded path of passed `Gemfile` during `eval_gemfile`
- fixes #4584
-rw-r--r-- | lib/bundler/dsl.rb | 6 | ||||
-rw-r--r-- | spec/install/gemfile/eval_gemfile_spec.rb | 42 |
2 files changed, 47 insertions, 1 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 224e642bd4..2c68a7b87a 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -34,7 +34,9 @@ module Bundler end def eval_gemfile(gemfile, contents = nil) - @gemfile = Pathname.new(gemfile) + expanded_gemfile_path = Pathname.new(gemfile).expand_path + original_gemfile = @gemfile + @gemfile = expanded_gemfile_path contents ||= Bundler.read_file(gemfile.to_s) instance_eval(contents, gemfile.to_s, 1) rescue Exception => e @@ -43,6 +45,8 @@ module Bundler "`#{File.basename gemfile.to_s}`: #{e.message}" raise DSLError.new(message, gemfile, e.backtrace, contents) + ensure + @gemfile = original_gemfile end def gemspec(opts = nil) diff --git a/spec/install/gemfile/eval_gemfile_spec.rb b/spec/install/gemfile/eval_gemfile_spec.rb new file mode 100644 index 0000000000..2660ac98c2 --- /dev/null +++ b/spec/install/gemfile/eval_gemfile_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true +require "spec_helper" + +describe "bundle install with gemfile that uses eval_gemfile" do + before do + build_lib("gunks", :path => bundled_app.join("gems/gunks")) do |s| + s.name = "gunks" + s.version = "0.0.1" + end + end + + context "eval-ed Gemfile points to an internal gemspec" do + before do + create_file "Gemfile-other", <<-G + gemspec :path => 'gems/gunks' + G + end + + it "installs the gemspec specified gem" do + install_gemfile <<-G + eval_gemfile 'Gemfile-other' + G + expect(out).to include("Resolving dependencies") + expect(out).to include("Using gunks 0.0.1 from source at `gems/gunks`") + expect(out).to include("Bundle complete") + end + end + + context "Gemfile uses gemspec paths after eval-ing a Gemfile" do + before { create_file "other/Gemfile-other" } + + it "installs the gemspec specified gem" do + install_gemfile <<-G + eval_gemfile 'other/Gemfile-other' + gemspec :path => 'gems/gunks' + G + expect(out).to include("Resolving dependencies") + expect(out).to include("Using gunks 0.0.1 from source at `gems/gunks`") + expect(out).to include("Bundle complete") + end + end +end |