Skip to content

Commit

Permalink
Fix up bundle init --gemspec
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbuddy authored and indirect committed Apr 20, 2010
1 parent 1d5b069 commit 0ce1001
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 11 additions & 3 deletions lib/bundler/rubygems_ext.rb
Expand Up @@ -27,8 +27,16 @@ def git_version

def to_gemfile(path = nil)
gemfile = "source :gemcutter\n"
gemfile << dependencies_to_gemfile(dependencies)
gemfile << dependencies_to_gemfile(development_dependencies, :development)
gemfile << dependencies_to_gemfile(nondevelopment_dependencies)
unless development_dependencies.empty?
gemfile << "\n"
gemfile << dependencies_to_gemfile(development_dependencies, :development)
end
gemfile
end

def nondevelopment_dependencies
dependencies - development_dependencies
end

def add_bundler_dependencies(*groups)
Expand All @@ -47,7 +55,7 @@ def add_bundler_dependencies(*groups)
def dependencies_to_gemfile(dependencies, group = nil)
gemfile = ''
if dependencies.any?
gemfile << "group #{group} do\n" if group
gemfile << "group :#{group} do\n" if group
dependencies.each do |dependency|
gemfile << ' ' if group
gemfile << %|gem "#{dependency.name}"|
Expand Down
5 changes: 3 additions & 2 deletions spec/other/init_spec.rb
Expand Up @@ -32,8 +32,9 @@

gemfile = bundled_app("Gemfile").read
gemfile.should =~ /source :gemcutter/
gemfile.should =~ /gem "rack", "= 1.0.1"/
gemfile.should =~ /gem "rspec", "= 1.2"/
gemfile.scan(/gem "rack", "= 1.0.1"/).size.should == 1
gemfile.scan(/gem "rspec", "= 1.2"/).size.should == 1
gemfile.scan(/group :development/).size.should == 1
end

end

0 comments on commit 0ce1001

Please sign in to comment.