Selecting Which Specs to Run

When you’re running your specs, you often want to change which ones you include. In this section, we’re going to show you a few different situations where this kind of slicing and dicing comes in handy.

Filtering

Most of the time when we start RSpec, we don’t run the entire suite. We’re either running unit specs for a specific class we’re designing or we’re kicking off some integration specs to catch regressions.

We first touched on running specific examples in Running Just What You Need. You saw how to select examples by pass/fail status, by our need to focus on them, and by custom tags. Let’s take a deeper dive into how to control which specs to run.

Excluding Examples

Sometimes, you want to exclude a set of examples ...

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.