summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbluehavana <bluehavana@gmail.com>2010-02-09 17:55:51 -0600
committerbluehavana <bluehavana@gmail.com>2010-02-09 17:55:51 -0600
commit34182ef4c41e47805cc92988d088d0abb439e27a (patch)
treec20e29ccf5b81d5a2ab7087469226056fcca1783
parent6c5a67dc849e7ed4dc1fc05176afcf6ae61ec776 (diff)
downloadbundler-34182ef4c41e47805cc92988d088d0abb439e27a.tar.gz
Fixed relative path issue (for something like gem "sample", :path => "vendor/sample") and added a spec.
-rw-r--r--lib/bundler/source.rb3
-rw-r--r--spec/install/path_spec.rb14
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index 727bb5bb5c..667f929a88 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -160,9 +160,10 @@ module Bundler
if File.directory?(path)
Dir["#{path}/#{@glob}"].each do |file|
file = Pathname.new(file)
+ relative_path = file.relative_path_from(Pathname.new(path))
# Do it in the root of the repo in case they do
# assume being in the root
- if spec = Dir.chdir(path) { eval(File.read(file)) }
+ if spec = Dir.chdir(path) { eval(File.read(relative_path)) }
spec = Specification.from_gemspec(spec)
spec.loaded_from = file
spec.source = self
diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb
index 83114122ca..f0bf66f28a 100644
--- a/spec/install/path_spec.rb
+++ b/spec/install/path_spec.rb
@@ -21,6 +21,18 @@ describe "gemfile install with explicit source paths" do
should_be_installed("foo 1.0")
end
+
+ it "supports relative paths" do
+ build_lib "foo"
+
+ relative_path = Pathname.new(lib_path('foo-1.0')).relative_path_from(Dir.pwd)
+
+ install_gemfile <<-G
+ gem 'foo', :path => "#{relative_path}"
+ G
+
+ should_be_installed("foo 1.0")
+ end
it "installs dependencies from the path even if a newer gem is available elsewhere" do
system_gems "rack-1.0.0"
@@ -50,7 +62,7 @@ describe "gemfile install with explicit source paths" do
build_lib "omg", "1.0", :path => lib_path("omg") do |s|
s.add_dependency "foo"
end
-
+
build_lib "foo", "1.0.0", :path => lib_path("omg/foo")
install_gemfile <<-G