summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-03-09 15:36:26 -0800
committerCarlhuda <carlhuda@engineyard.com>2010-03-09 15:36:26 -0800
commit3685d0ba3740af853943aabab3d2e56ae8a9e7d7 (patch)
treec9631abbf7454a9333264f0ac891e92ecbfe200e
parentf278f83d1de4caa8b745e8189b26393e0a08e72f (diff)
downloadbundler-3685d0ba3740af853943aabab3d2e56ae8a9e7d7.tar.gz
Add the ability to specify a gem in multiple groups
-rw-r--r--lib/bundler/dsl.rb10
-rw-r--r--spec/install/gems_spec.rb120
2 files changed, 82 insertions, 48 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 309058a588..dffa4d8e14 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -12,14 +12,14 @@ module Bundler
@source = nil
@sources = []
@dependencies = []
- @group = nil
+ @group = [:default]
end
def gem(name, *args)
options = Hash === args.last ? args.pop : {}
version = args.last || ">= 0"
- if options[:group]
- options[:group] = options[:group].to_sym
+ if group = options[:groups] || options[:group]
+ options[:group] = group
end
_deprecated_options(options)
@@ -55,8 +55,8 @@ module Bundler
Definition.new(@dependencies, @sources)
end
- def group(name, options = {}, &blk)
- old, @group = @group, name.to_sym
+ def group(*args, &blk)
+ old, @group = @group, args
yield
ensure
@group = old
diff --git a/spec/install/gems_spec.rb b/spec/install/gems_spec.rb
index 5ce4704466..a41bdf6c49 100644
--- a/spec/install/gems_spec.rb
+++ b/spec/install/gems_spec.rb
@@ -443,59 +443,93 @@ describe "bundle install with gem sources" do
end
describe "installing --without" do
- before :each do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- group :emo do
- gem "activesupport", "2.3.5"
- end
- G
- end
+ describe "with gems assigned to a single group" do
+ before :each do
+ 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
- bundle :install, :without => "emo"
- should_be_installed "rack 1.0.0", :groups => [:default]
- end
+ it "installs gems in the default group" do
+ bundle :install, :without => "emo"
+ should_be_installed "rack 1.0.0", :groups => [:default]
+ end
- it "does not install gems from the excluded group" do
- bundle :install, :without => "emo"
- should_not_be_installed "activesupport 2.3.5", :groups => [:default]
- end
+ it "does not install gems from the excluded group" do
+ bundle :install, :without => "emo"
+ should_not_be_installed "activesupport 2.3.5", :groups => [:default]
+ end
- it "does not say it installed gems from the excluded group" do
- bundle :install, :without => "emo"
- out.should_not include("activesupport")
- end
+ it "does not say it installed gems from the excluded group" do
+ bundle :install, :without => "emo"
+ out.should_not include("activesupport")
+ end
- it "allows Bundler.setup for specific groups" do
- bundle :install, :without => "emo"
- run("require 'rack'; puts RACK", :default)
- out.should == '1.0.0'
- end
+ it "allows Bundler.setup for specific groups" do
+ bundle :install, :without => "emo"
+ run("require 'rack'; puts RACK", :default)
+ out.should == '1.0.0'
+ end
- it "does not effect the resolve" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "activesupport"
- group :emo do
- gem "rails", "2.3.2"
- end
- G
+ it "does not effect the resolve" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "activesupport"
+ group :emo do
+ gem "rails", "2.3.2"
+ end
+ G
+
+ bundle :install, :without => "emo"
+ should_be_installed "activesupport 2.3.2", :groups => [:default]
+ end
+
+ it "still works when locked" do
+ bundle :install, :without => "emo"
+ bundle :lock
+
+ simulate_new_machine
+ bundle :install, :without => "emo"
- bundle :install, :without => "emo"
- should_be_installed "activesupport 2.3.2", :groups => [:default]
+ should_be_installed "rack 1.0.0", :groups => [:default]
+ should_not_be_installed "activesupport 2.3.5", :groups => [:default]
+ end
end
- it "still works when locked" do
- bundle :install, :without => "emo"
- bundle :lock
+ describe "with gems assigned to multiple groups" do
+ before :each do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ group :emo, :lolercoaster do
+ gem "activesupport", "2.3.5"
+ end
+ G
+ end
- simulate_new_machine
- bundle :install, :without => "emo"
+ it "installs gems in the default group" do
+ bundle :install, :without => "emo lolercoaster"
+ should_be_installed "rack 1.0.0"
+ end
- should_be_installed "rack 1.0.0", :groups => [:default]
- should_not_be_installed "activesupport 2.3.5", :groups => [:default]
+ it "installs the gem if any of its groups are installed" do
+ bundle "install --without emo"
+ should_be_installed "rack 1.0.0", "activesupport 2.3.5"
+ end
+
+ it "works when locked as well" do
+ bundle "install --without emo"
+ bundle "lock"
+
+ simulate_new_machine
+
+ bundle "install --without lolercoaster"
+ should_be_installed "rack 1.0.0", "activesupport 2.3.5"
+ end
end
end
end