Browse Source

double gsub to properly get title for BootXChange

thanks to @passcod for this
phinze 12 years ago
parent
commit
f1221be6c2
  1. 2
      lib/cask.rb
  2. 12
      test/cask_test.rb

2
lib/cask.rb

@ -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

12
test/cask_test.rb

@ -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

Loading…
Cancel
Save