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

Whew! We gave you a lot to chew on in this chapter, from broad advice on test doubles to fine-grained design nuances. Here are just some of the principles we explored over several code examples:

  • Construct your test environment carefully.
  • Watch out for the “stubject.”
  • Know the risks of partial doubles.
  • Favor explicit dependency injection over more implicit techniques.
  • Avoid faking an interface you don’t control.
  • Look for high-fidelity fakes.
  • Wrap third-party interfaces.

That’s a lot to keep in your head, but we’re definitely not asking you to do that! All of these bits of advice stem from one key practice: constructing your test environment carefully. Remember the laboratory metaphor when you’re writing your specs, and you should be fine.

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