Your Turn
In this chapter, you installed RSpec and took it for a test drive. You wrote a few simple specs to get a feel for the major parts of the framework. You saw how to run your examples and interpret the output. Finally, you explored a few different ways to reduce duplication in your specs.
Now, it’s time to put this knowledge to the test.
Exercises
-
We’ve shown you three primary ways to reduce duplication in RSpec: hooks, helper methods, and let declarations. Which way did you like best for this example? Why? Can you think of situations where the others might be a better option?
-
Run rspec --help and look at the available options. Try using a few of them to run your sandwich examples.
Ready to see some of our favorite ways to use RSpec? ...
Get Effective Testing with RSpec 3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.