double gsub to properly get title for BootXChange
thanks to @passcod for this
This commit is contained in:
parent
4bd1543a9b
commit
f1221be6c2
|
@ -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
|
||||
|
|
|
@ -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…
Reference in New Issue