Permalink
Browse files

fix relative_path so it checks Bundler.root

is actually in the beginning of the path
  • Loading branch information...
1 parent 3b836fc commit 4b9ca12bf4d844838b64562b52595e142aba0a74 @hone hone committed Dec 9, 2011
Showing with 26 additions and 1 deletion.
  1. +1 −1 lib/bundler/source.rb
  2. +25 −0 spec/runtime/setup_spec.rb
@@ -415,7 +415,7 @@ def cache(spec)
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
@@ -567,6 +567,31 @@
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

0 comments on commit 4b9ca12

Please sign in to comment.