summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Arko <website+github.com@arko.net>2011-12-08 17:39:22 -0800
committerAndré Arko <website+github.com@arko.net>2011-12-08 17:39:22 -0800
commit6d431b8528ec11c3aa7cd10965846a7b965c5c66 (patch)
tree0478d435f234d6cb7eb1618f142a4a41b8e4535b
parent3b836fc5f6b7aec1fd7cbe0da316b6ddc0d9f613 (diff)
parent4b9ca12bf4d844838b64562b52595e142aba0a74 (diff)
downloadbundler-6d431b8528ec11c3aa7cd10965846a7b965c5c66.tar.gz
Merge pull request #1582 from carlhuda/relative_path
fix relative_path so it checks Bundler.root is actually in the beginning of the path
-rw-r--r--lib/bundler/source.rb2
-rw-r--r--spec/runtime/setup_spec.rb25
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index 7a2f645441..126e7fc4b7 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -415,7 +415,7 @@ module Bundler
private
def relative_path
- if path.to_s.include?(Bundler.root.to_s)
+ if path.to_s.match(%r{^#{Bundler.root.to_s}})
return path.relative_path_from(Bundler.root)
end
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index 5a77db980d..4fe8d284fe 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -567,6 +567,31 @@ describe "Bundler.setup" do
end
err.should == ""
end
+
+ it "should make sure the Bundler.root is really included in the path relative to the Gemfile" do
+ relative_path = File.join('vendor', Dir.pwd[1..-1], 'foo')
+ absolute_path = bundled_app(relative_path)
+ FileUtils.mkdir_p(absolute_path)
+ build_lib "foo", :path => absolute_path
+
+ # If the .gemspec exists, then Bundler handles the path differently.
+ # See Source::Path.load_spec_files for details.
+ FileUtils.rm(File.join(absolute_path, 'foo.gemspec'))
+
+ gemfile <<-G
+ gem 'foo', '1.2.3', :path => '#{relative_path}'
+ G
+
+ bundle :install
+
+ Dir.chdir(bundled_app.parent) do
+ run <<-R, :env => {"BUNDLE_GEMFILE" => bundled_app('Gemfile')}
+ require 'foo'
+ R
+ end
+
+ err.should == ""
+ end
end
describe "with git gems that don't have gemspecs" do