-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to convert a number to a cardinal numeral
- Loading branch information
1 parent
a8352ae
commit da5f2ed
Showing
2 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Strings::Numeral, "#cardinalize" do | ||
{ | ||
0 => "zero", | ||
1 => "one", | ||
20 => "twenty", | ||
21 => "twenty one", | ||
100 => "one hundred", | ||
101 => "one hundred one", | ||
111 => "one hundred eleven", | ||
113 => "one hundred thirteen", | ||
123 => "one hundred twenty three", | ||
1234 => "one thousand, two hundred thirty four", | ||
12345 => "twelve thousand, three hundred forty five", | ||
123456 => "one hundred twenty three thousand, four hundred fifty six", | ||
1234567 => "one million, two hundred thirty four thousand, five hundred sixty seven" | ||
}.each do |num, word| | ||
it "cardinalizes #{num.inspect} to #{word.inspect}" do | ||
expect(Strings::Numeral.cardinalize(num)).to eq(word) | ||
end | ||
end | ||
end |