Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add the ability to specify a gem in multiple groups

  • Loading branch information...
commit 3685d0ba3740af853943aabab3d2e56ae8a9e7d7 1 parent f278f83
Carlhuda authored
Showing with 82 additions and 48 deletions.
  1. +5 −5 lib/bundler/dsl.rb
  2. +77 −43 spec/install/gems_spec.rb
View
10 lib/bundler/dsl.rb
@@ -12,14 +12,14 @@ def initialize
@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 @@ def to_definition
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
View
120 spec/install/gems_spec.rb
@@ -443,59 +443,93 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.