Chapter 4. Setting Up and Cleaning Up

This chapter discusses support code to set tests up and clean up after them. Initialization, configuration, cleanup, and other support code related to RSpec specs are important in real-world RSpec usage. We will learn how to cleanly organize support code in real-world applications by learning about the following topics:

  • Configuring RSpec with spec_helper.rb
  • Initialization and configuration of resources
  • Preventing tests from accessing the Internet with WebMock
  • Maintaining clean test state
  • Custom helper code
  • Loading support code on demand with tags

Configuring RSpec with spec_helper.rb

The RSpec specs that we've seen so far have functioned as standalone units. Specs in the real world, however, almost never work without ...

Get RSpec Essentials 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.