summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-01-28 16:51:04 -0800
committerCarlhuda <carlhuda@engineyard.com>2010-01-28 16:51:04 -0800
commita127e768fa573d1dad06c2de50b774993d8fb239 (patch)
tree5b57642f27ccfb8013790e8f9e1667dba5bf313a
parent8637b672564c5f48681d37a41fb5b6988ed524f8 (diff)
downloadbundler-a127e768fa573d1dad06c2de50b774993d8fb239.tar.gz
Add support for Bundler.setup(*groups)
-rw-r--r--lib/bundler/dependency.rb2
-rw-r--r--lib/bundler/environment.rb4
-rw-r--r--spec/install/gems_spec.rb39
-rw-r--r--spec/support/helpers.rb5
4 files changed, 46 insertions, 4 deletions
diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb
index 253efafd57..c5a685ec1b 100644
--- a/lib/bundler/dependency.rb
+++ b/lib/bundler/dependency.rb
@@ -7,7 +7,7 @@ module Bundler
def initialize(name, version, options = {}, &blk)
super(name, version)
- @group = options["group"]
+ @group = options["group"] || :default
end
end
end \ No newline at end of file
diff --git a/lib/bundler/environment.rb b/lib/bundler/environment.rb
index b5d52d9f99..08cc2f3ff0 100644
--- a/lib/bundler/environment.rb
+++ b/lib/bundler/environment.rb
@@ -31,7 +31,9 @@ module Bundler
def specs_for(*groups)
return specs if groups.empty?
- specs.select { |s| (s.groups & groups).any? }
+
+ dependencies = @definition.actual_dependencies.select { |d| groups.include?(d.group) }
+ Resolver.resolve(dependencies, index)
end
def specs
diff --git a/spec/install/gems_spec.rb b/spec/install/gems_spec.rb
index c727cc5c57..70e3404b1c 100644
--- a/spec/install/gems_spec.rb
+++ b/spec/install/gems_spec.rb
@@ -170,6 +170,40 @@ describe "gemfile install with gem sources" do
end
end
+ describe "when specifying groups not excluded" do
+ before :each do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ group :emo do
+ gem "activesupport", "2.3.5"
+ end
+ G
+ end
+
+ it "installs gems in the default group" do
+ out = ruby <<-G
+ begin ; require 'rubygems' ; require 'rack' ; puts "WIN" ; end
+ G
+ out.should == "WIN"
+ end
+
+ it "installs gems in other groups" do
+ out = ruby <<-G
+ begin ; require 'rubygems' ; require 'activesupport' ; puts "WIN" ; end
+ G
+ out.should == "WIN"
+ end
+
+ it "sets up everything if Bundler.setup is used with no groups" do
+ out = run("require 'rack'; puts RACK")
+ out.should == '1.0.0'
+
+ out = run("require 'activesupport'; puts ACTIVESUPPORT")
+ out.should == '2.3.5'
+ end
+ end
+
describe "when excluding groups" do
before :each do
install_gemfile <<-G, 'without' => 'emo'
@@ -198,5 +232,10 @@ describe "gemfile install with gem sources" do
out.should == 'WIN'
end
+
+ it "allows Bundler.setup for specific groups" do
+ out = run("require 'rack'; puts RACK", :default)
+ out.should == '1.0.0'
+ end
end
end \ No newline at end of file
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 72c0121da9..d950a9a156 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -27,8 +27,9 @@ module Spec
@out = ruby "-r #{env}", cmd
end
- def run(cmd)
- setup = "require 'rubygems' ; require 'bundler' ; Bundler.setup\n"
+ def run(cmd, *args)
+ groups = args.map {|a| a.inspect }.join(", ")
+ setup = "require 'rubygems' ; require 'bundler' ; Bundler.setup(#{groups})\n"
@out = ruby(setup + cmd)
end