RSpec.configure

You’ve seen how easily you can set configuration options for a particular spec run via the command line. You’ve also seen how to make your favorite options the default using .rspec files.

As convenient as they are, command-line flags are not available for all RSpec options—just the ones you’re likely to change from run to run. For the rest, you’ll need to call RSpec.configure inside one or more Ruby files. You can have multiple configure blocks in your code base; if you do, RSpec will combine the options from all of them.

On a typical project, you’ll put setup in spec/spec_helper.rb and then load this file automatically by adding --require spec_helper to your .rspec file.

Be Careful What You Load from spec_helper.rb

It’s easy ...

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.