double gsub to properly get title for BootXChange

thanks to @passcod for this
This commit is contained in:
phinze 2012-12-17 16:59:58 -07:00
parent 4bd1543a9b
commit f1221be6c2
2 changed files with 13 additions and 1 deletions

View File

@ -48,7 +48,7 @@ class Cask
end
def self.title
self.name.gsub(/([a-z\d])([A-Z])/,'\1-\2').downcase
self.name.gsub(/([a-zA-Z\d])([A-Z])/,'\1-\2').gsub(/([a-zA-Z\d])([A-Z])/,'\1-\2').downcase
end
attr_reader :title

View File

@ -22,4 +22,16 @@ describe Cask do
all_casks.each { |cask| cask.must_be_kind_of String }
end
end
describe "title" do
it "converts class constant to dasherized string" do
PascalCasedConstant = Class.new(Cask)
PascalCasedConstant.title.must_equal 'pascal-cased-constant'
end
it "properly dasherizes constants with single letters in the middle" do
GamesXChange = Class.new(Cask)
GamesXChange.title.must_equal 'games-x-change'
end
end
end