We cover:

  • What kind of information RSpec stores about each spec
  • How you can tag your examples with custom information
  • How to perform expensive setup only when you need to
  • How to run just a subset of your specs

Chapter 8
Slicing and Dicing Specs with Metadata

Over the course of this book, you’ve followed a key principle that has made your specs faster, more reliable, and easier to use: run just the code you need. This principle shows up in several practices you’ve been using as you’ve followed along with the code examples:

  • When you’re isolating a failure, run just the failing example.
  • When you’re modifying a class, run just its unit tests.
  • When you’ve got expensive setup code, only run it for the specs where you need it.

A key piece of RSpec that’s made many of these practices possible is its powerful metadata system. Metadata undergirds many of RSpec’s features, and RSpec exposes the same system for your use.

You’ve used metadata several times so far in your examples. In this chapter, we’ll take a closer look into how it works. By the end, you’ll understand enough to dictate exactly when and how your specs run.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset