Permalink
Browse files

String#capitalize downcases the rest of the string :(

fixes #1303
  • Loading branch information...
indirect committed Sep 18, 2011
1 parent f430776 commit ba7e1b082a45460cacefe0eb5c67b2632c4ee498
Showing with 9 additions and 2 deletions.
  1. +2 −2 lib/bundler/cli.rb
  2. +7 −0 spec/bundler/gem_helper_spec.rb
View
@@ -475,8 +475,8 @@ def viz
def gem(name)
name = name.chomp("/") # remove trailing slash if present
target = File.join(Dir.pwd, name)
- constant_name = name.split('_').map{|p| p.capitalize}.join
- constant_name = constant_name.split('-').map{|q| q.capitalize}.join('::') if constant_name =~ /-/
+ constant_name = name.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join
+ constant_name = constant_name.split('-').map{|q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/
constant_array = constant_name.split('::')
git_author_name = `git config user.name`.chomp
git_author_email = `git config user.email`.chomp
@@ -31,6 +31,13 @@
File.open(File.join(app.to_s, 'test2.gemspec'), 'w') {|f| f << ''}
proc { Bundler::GemHelper.new(app.to_s) }.should raise_error(/Unable to determine name/)
end
+
+ it "handles namespaces and converting to CamelCase" do
+ bundle 'gem test-foo_bar'
+ lib = bundled_app('test-foo_bar').join('lib/test-foo_bar.rb').read
+ lib.should include("module Test")
+ lib.should include("module FooBar")
+ end
end
context "gem management" do

0 comments on commit ba7e1b0

Please sign in to comment.