https://github.com/dansteele/number_to_words
Test-driven practice
https://github.com/dansteele/number_to_words
Last synced: 5 months ago
JSON representation
Test-driven practice
- Host: GitHub
- URL: https://github.com/dansteele/number_to_words
- Owner: dansteele
- Created: 2015-01-20T13:33:25.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2022-07-18T12:09:51.000Z (almost 4 years ago)
- Last Synced: 2024-04-24T09:18:20.868Z (about 2 years ago)
- Language: Ruby
- Size: 55.7 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
TDD - Numbers to Words
======================
TO RUN
------
> ruby numbers_to_words_spec.rb
TODO
----
* Repeatedly run the test until you get get test failures, rather than any Ruby exceptions. You should see
```
1) Failure:
to_words#test_0001_should handle individual numbers [numbers_to_words_spec.rb:7]:
Expected: "one"
Actual: nil
```
* Add just enough code to your `to_words` method to make the test pass.
* Add the following code to your spec.
```
it "should handle the teens" do
16.to_words.must_equal("sixteen")
19.to_words.must_equal("nineteen")
end
```
* Run the updated spec, *see it fail*, and then implement the solution. N.B. the
solution only has to work for numbers less than twenty; is your solution trying
to implement more than what is required?
* Add code to your spec that tests words up to one hundred. See the test fail
first, then implement the solution. What changes are needed? If you need to
implement any further methods, write them *test first*.
* Once you achieve one hundred, repeat the process up until one thousand.
* Once you achieve one thousand, repeat the process up until one million.