O'Reilly logo

Effective Testing with RSpec 3 by Myron Marston, Ian Dees

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

  1. 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?

  2. 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? ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required