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

Running Just What You Need

In the examples in this chapter, we’ve always run all the specs together. On a real project, you don’t necessarily want to load your entire test suite every time you invoke RSpec.

If you’re diagnosing a specific failure, for instance, you’ll want to run just that one example. If you’re trying to get rapid feedback on your design, you can bypass slow or unrelated specs.

The easiest way to narrow down your test run is to pass a list of file or directory names to rspec:

 $ ​​rspec​​ ​​spec/unit​​ # Load *_spec.rb in this dir and subdirs
 $ ​​rspec​​ ​​spec/unit/specific_spec.rb​​ # Load just one spec file
 $ ​​rspec​​ ​​spec/unit​​ ​​spec/smoke​​ # Load more than one directory
 $ ​​rspec​​ ​​spec/unit​​ ​​spec/foo_spec.rb ...

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