Browse files

Fix up bundle init --gemspec

  • Loading branch information...
1 parent 1d5b069 commit 0ce100171e9863b0ba82dc004c772ae2dcd74757 @joshbuddy joshbuddy committed with indirect Apr 20, 2010
Showing with 14 additions and 5 deletions.
  1. +11 −3 lib/bundler/rubygems_ext.rb
  2. +3 −2 spec/other/init_spec.rb
View
14 lib/bundler/rubygems_ext.rb
@@ -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)
@@ -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}"|
View
5 spec/other/init_spec.rb
@@ -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.