From the course: Ruby: Testing with RSpec

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Solution: NumberHelper

Solution: NumberHelper - Ruby Tutorial

From the course: Ruby: Testing with RSpec

Start my 1-month free trial

Solution: NumberHelper

- Hopefully you were able to complete the NumberHelper challenge on your own. But if not, in this movie, I'll show you the solution that I came up with. Remember, we already have a skeleton for our spec. And I have two contexts, using default values, and using custom options. Let's start with the first one for using default values. I gave you the first answer, that it should correctly format an integer. I used 2000 and I tried to stick with 2000 through most of my test, or some variation of it. So if we use number_to_currency on 2000 we should get back the string $2,000.00. It should do the same thing if we pass it in a float. So here I gave it a floating point number, and I should get back the same value. Or if I give it a string. It shouldn't matter what type it is, it should successfully convert it into a well-formatted currency string. Then I have an example for the fact that it uses delimiters when we have large numbers. So I just picked a very large number by throwing a lot of…

Contents