From the course: Ruby: Testing with RSpec

Unlock the full course today

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

Challenge: NumberHelper

Challenge: NumberHelper - Ruby Tutorial

From the course: Ruby: Testing with RSpec

Start my 1-month free trial

Challenge: NumberHelper

- Your first challenge is to write the specs for the NumberHelper module. Let me start by giving you a few pointers. Whenever writing specs, I think it's a good idea to spend a few minutes thinking about what to test. When you look over the code, what parts of it need testing? It can be useful to think about the happy path or the path where everything goes exactly as you've planned, as well as the many possible unhappy paths where things go wrong. Or to think about some of the edge cases that you might encounter, where the possible even though less common events happen. For example, you may have code that works correctly when given an integer as an argument but does it still gracefully handle cases when the argument is a string, a float, nil or an array? Should it? It can also be helpful to consider basic usage versus advanced usage, that's gonna be the case with the NumberHelper. We can simply pass in a number as the only argument and get to default behavior or we can pass in options…

Contents