diff options
author | wycats <wycats@gmail.com> | 2010-07-15 20:58:03 -0500 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-07-15 22:43:45 -0500 |
commit | 7078db948751cdc4626bd65509f65bdc371656ba (patch) | |
tree | 5b46a66b73a2cbadf1ae2ef24eee483ce32dfdb0 | |
parent | a0082b979c0c60b0ba49fce99c173d80794c3d50 (diff) | |
download | bundler-7078db948751cdc4626bd65509f65bdc371656ba.tar.gz |
Actually test #gemspec and deprecate #add_bundler_dependencies
-rw-r--r-- | lib/bundler/dsl.rb | 4 | ||||
-rw-r--r-- | lib/bundler/rubygems_ext.rb | 5 | ||||
-rw-r--r-- | spec/install/path_spec.rb | 58 |
3 files changed, 66 insertions, 1 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index e2994e4b26..6f63f79205 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -20,14 +20,16 @@ module Bundler @env = nil end - def gemspec(opts) + def gemspec(opts = nil) path = opts && opts[:path] || '.' name = opts && opts[:name] || '*' development_group = opts && opts[:development_group] || :development gemspecs = Dir[File.join(path, "#{name}.gemspec")] + case gemspecs.size when 1 spec = Gem::Specification.load(gemspecs.first) + gem spec.name, :path => path spec.runtime_dependencies.each do |dep| gem dep.name, dep.requirement.to_s end diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index 2eb81b3778..8429d439a3 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -111,6 +111,11 @@ module Gem end def add_bundler_dependencies(*groups) + Bundler.ui.warn "#add_bundler_dependencies is deprecated and will " \ + "be removed in Bundler 1.0. Instead, please use the #gemspec method " \ + "in your Gemfile, which will pull in any dependencies specified in " \ + "your gemspec" + groups = [:default] if groups.empty? Bundler.definition.dependencies.each do |dep| if dep.groups.include?(:development) diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb index e6908e9861..38b778b051 100644 --- a/spec/install/path_spec.rb +++ b/spec/install/path_spec.rb @@ -84,6 +84,64 @@ describe "bundle install with explicit source paths" do should_be_installed "foo 1.0" end + it "supports gemspec syntax" do + build_lib "foo", "1.0", :path => lib_path("foo") do |s| + s.add_dependency "rack", "1.0" + end + + gemfile = <<-G + source "file://#{gem_repo1}" + gemspec + G + + File.open(lib_path("foo/Gemfile"), "w") {|f| f.puts gemfile } + + Dir.chdir(lib_path("foo")) do + bundle "install" + should_be_installed "foo 1.0" + should_be_installed "rack 1.0" + end + end + + it "supports gemspec syntax with an alternative path" do + build_lib "foo", "1.0", :path => lib_path("foo") do |s| + s.add_dependency "rack", "1.0" + end + + install_gemfile <<-G + source "file://#{gem_repo1}" + gemspec :path => "#{lib_path("foo")}" + G + + should_be_installed "foo 1.0" + should_be_installed "rack 1.0" + end + + it "raises if there are multiple gemspecs" do + build_lib "foo", "1.0", :path => lib_path("foo") do |s| + s.write "bar.gemspec" + end + + install_gemfile <<-G, :exit_status => true + gemspec :path => "#{lib_path("foo")}" + G + + @exitstatus.should == 15 + out.should =~ /There are multiple gemspecs/ + end + + it "allows :name to be specified to resolve ambiguity" do + build_lib "foo", "1.0", :path => lib_path("foo") do |s| + s.write "bar.gemspec" + end + + install_gemfile <<-G, :exit_status => true + gemspec :path => "#{lib_path("foo")}", :name => "foo" + G + + should_be_installed "foo 1.0" + end + it "sets up executables" do pending_jruby_shebang_fix |