80

When I run rspec with rake rspec and my tests are not ok, I get an error message. However, when my tests are ok, I just get '..'. No other output. How can I get it to print something like:

A User .... can only have one name
A User .... can ...
Jared Beck
  • 16,796
  • 9
  • 72
  • 97
Spyros
  • 46,820
  • 25
  • 86
  • 129

3 Answers3

134

From the rspec help page

$ rspec --help
Usage: rspec [options] [files or directories]

    -f, --format FORMATTER           Choose a formatter
                                       [p]rogress (default - dots)
                                       [d]ocumentation (group and example names)
                                       [h]tml
                                       [t]extmate
                                       custom formatter class name

Pass the -f parameter. Instead of

$ rake rspec

run

$ rspec spec --format d

or short format:

$ rspec -fd

If you want the configuration to be permanent, create a .rspec file in the root of your project and write there the configurations.

iwasrobbed
  • 46,496
  • 21
  • 150
  • 195
Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
  • 19
    rspec -fd if you want it short and sweet. rspec -c -fd if you would like to see the output in colour on your screen :) – rmk Feb 22 '11 at 20:56
  • 4
    You can also make this options default putting them into your `.rspec` file. I have `--color --tty --format documentation` (by one --option per line). – Dan K.K. Feb 20 '14 at 16:45
19

Inside your spec/spec_helper

RSpec.configure do |config|
  config.formatter = :documentation
end

so you don't have to run the flag everytime.

Sam Kah Chiin
  • 4,375
  • 5
  • 25
  • 30
7

Use:

rspec spec --format documentation
David Cain
  • 16,484
  • 14
  • 65
  • 75
Nitesh
  • 266
  • 4
  • 11
  • 2
    I would argue that it does - the command in question does exactly what the question asked. Nevertheless, there was already an (accepted) answer that stated the same thing, so this answer doesn't add any real value. – javawizard Nov 06 '14 at 18:18