Logo: Relish

  1. Sign in

Project: RSpec Core 3.1

Command line

The rspec command comes with several options you can use to customize RSpec's
behavior, including output formats, filtering examples, etc.

For a full list of options, run the rspec command with the --help flag:

$ rspec --help

Run with ruby

Generally, life is simpler if you just use the rspec command. If you must use
the ruby command, however, you'll need to require rspec/autorun. You can
either pass a -rrspec/autorun CLI option when invoking ruby, or add a
require 'rspec/autorun' to one or more of your spec files.

It is conventional to put configuration in and require assorted support files
from spec/spec_helper.rb. It is also conventional to require that file from
the spec files using require 'spec_helper'. This works because RSpec
implicitly adds the spec directory to the LOAD_PATH. It also adds lib, so
your implementation files will be on the LOAD_PATH as well.

If you're using the ruby command, you'll need to do this yourself (with the
-I option). Putting these together, your command might be something like this:

$ ruby -Ilib -Ispec -rrspec/autorun path/to/spec.rb


  1. `--example` option
  2. `--format` option
  3. `--tag` option
  4. line number appended to file path
  5. `--failure-exit-code` option (exit status)
  6. `--order` option
  7. rake task
  8. `--dry-run` option
  9. `--fail-fast` option
  10. `--init` option
  11. `--pattern` option
  12. `--require` option
  13. `--warnings` option (run with warnings enabled)
  14. Randomization can be reproduced across test runs
  15. run with `ruby` command

Last published over 7 years ago by myronmarston.