What Your Specs Are Doing for You

Writing specs isn’t the goal of using RSpec—it’s the benefits those specs provide. Let’s talk about those benefits now; they’re not all as obvious as “specs catch bugs.”

Creating Confidence

Specs increase confidence in your project. We’re not talking about the simplistic view that if your specs pass, your program is bug-free (we’ve been programming in the real world for far too long to believe that fairy tale).

When we say confidence, we mean that a well-written spec can provide evidence in favor of certain claims about your code. For instance:

  • The “happy path” through a particular bit of code behaves the way you want it to.

  • A method detects and reacts to an error condition you’re anticipating.

  • That last feature ...

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.