O'Reilly logo

Effective Testing with RSpec 3 by Myron Marston, Ian Dees

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required