Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rspec Output Format: Documentation

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 ...
like image 816
Spyros Avatar asked Feb 22 '11 20:02

Spyros


3 Answers

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.

like image 76
Simone Carletti Avatar answered Oct 31 '22 23:10

Simone Carletti


Inside your spec/spec_helper

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

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

like image 18
Sam Kah Chiin Avatar answered Oct 31 '22 23:10

Sam Kah Chiin


Use:

rspec spec --format documentation
like image 7
Nitesh Avatar answered Nov 01 '22 00:11

Nitesh