| 1 |
(require 'behave) |
| 2 |
|
| 3 |
(context "Testing if string is camelized" |
| 4 |
(tag rails rails-lib camelized-p) |
| 5 |
(specify "should be nil if there are no capital characters" |
| 6 |
(expect (camelized-p "horse") equal nil)) |
| 7 |
(specify "should be 0 for a word with first character being a capital" |
| 8 |
(expect (camelized-p "Horse") equal 0)) |
| 9 |
(specify "should be nil if the first character is not a capital" |
| 10 |
(expect (camelized-p "dragonFly") equal nil)) |
| 11 |
(specify "should be 0 if there are multiple capitals" |
| 12 |
(expect (camelized-p "DragonFly") equal 0)) |
| 13 |
(specify "should be 0 if it has numbers" |
| 14 |
(expect (camelized-p "DragonFly69") equal 0)) |
| 15 |
(specify "should be nil if all its characters are capital" |
| 16 |
(expect (camelized-p "DONKEY") equal nil))) |
| 17 |
|
| 18 |
(context "Testing if string is underscored" |
| 19 |
(tag rails rails-lib underscored-p) |
| 20 |
(specify "should be nil if there is a capital character" |
| 21 |
(expect (underscored-p "horSe") equal nil)) |
| 22 |
(specify "should be 0 if all characters are lowercase" |
| 23 |
(expect (underscored-p "horse") equal 0)) |
| 24 |
(specify "should be 0 if some characters are numbers" |
| 25 |
(expect (underscored-p "horse12") equal 0)) |
| 26 |
(specify "should be 0 if some characters are underscores" |
| 27 |
(expect (underscored-p "dragon_fly") equal 0)) |
| 28 |
(specify "should be nil if the first character is not a letter" |
| 29 |
(expect (underscored-p "5_gold_rings") equal nil)) |
| 30 |
) |
| 31 |
|
| 32 |
(context "Decamelizing" |
| 33 |
(tag rails rails-lib decamelize) |
| 34 |
(specify "should return a string of all lower case characters unchanged" |
| 35 |
(expect (decamelize "horse") equal "horse")) |
| 36 |
(specify "should replace an initial capital with a lower case character" |
| 37 |
(expect (decamelize "Horse") equal "horse")) |
| 38 |
(specify "should insert underscores before capital letters" |
| 39 |
(expect (decamelize "AntEaterTongue") equal "ant_eater_tongue")) |
| 40 |
(specify "should insert one underscore after last character of serie of capitals" |
| 41 |
(expect (decamelize "SMSMessage") equal "sms_message")) |
| 42 |
(specify "should insert an underscore between a digit and a capital" |
| 43 |
(expect (decamelize "Dalmatien101Movie") equal "dalmatien101_movie")) |
| 44 |
) |