Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Merge pull request #8 from chadrosen/add-support-for-multiple-groups
Browse files Browse the repository at this point in the history
add suport for multi-groups and tests
  • Loading branch information
bigloser committed May 30, 2014
2 parents 7811f9e + 044ed80 commit c89c4b2
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/ext/bundler_fake_dsl.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Bundler
class FakeDsl

def initialize(file)
@groups = Hash.new{|h, k| h[k] = []}
@gems = []
Expand All @@ -19,18 +19,20 @@ def __gem_names
__gems.map(&:first)
end

def group(name, &blk)
@current_group = name.to_sym
instance_eval(&blk)
@current_group = nil
def group(*group_names, &blk)
group_names.each do |name|
@current_group = name.to_sym
instance_eval(&blk)
@current_group = nil
end
end
alias_method :groups, :group

def gem(*args)
@gems << args
@groups[@current_group] << args.first
end

def method_missing(*args)
end
end
Expand Down
52 changes: 52 additions & 0 deletions spec/spitball_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,55 @@
end
end
end

describe Bundler::FakeDsl do
it "should support a single group" do
gemfile = <<-end_gemfile
source :rubygems
gem "json_pure"
group :development do
gem 'rails'
gem 'json_pure'
end
end_gemfile

dsl = Bundler::FakeDsl.new(gemfile)
dsl.__groups[:development].should == ["rails", "json_pure"]
end

it "should support multiple groups in one line" do
gemfile = <<-end_gemfile
source :rubygems
gem "json_pure"
group :development, :test do
gem 'rails'
gem 'json_pure'
end
end_gemfile

dsl = Bundler::FakeDsl.new(gemfile)
dsl.__groups[:development].should == ["rails", "json_pure"]
dsl.__groups[:test].should == ["rails", "json_pure"]
end

it "should support multiple groups on several lines" do
gemfile = <<-end_gemfile
source :rubygems
gem "json_pure"
group :development do
gem 'rails'
end
group :test do
gem 'json_pure'
end
end_gemfile

dsl = Bundler::FakeDsl.new(gemfile)
dsl.__groups[:development].should == ["rails"]
dsl.__groups[:test].should == ["json_pure"]
end
end

0 comments on commit c89c4b2

Please sign in to comment.