Rspec Output Format: Documentation

Ruby on-RailsRubyRspec

Ruby on-Rails Problem Overview


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

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

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.

Solution 2 - Ruby on-Rails

Inside your spec/spec_helper

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

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

Solution 3 - Ruby on-Rails

Use:

rspec spec --format documentation

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSpyrosView Question on Stackoverflow
Solution 1 - Ruby on-RailsSimone CarlettiView Answer on Stackoverflow
Solution 2 - Ruby on-RailsSam Kah ChiinView Answer on Stackoverflow
Solution 3 - Ruby on-RailsNiteshView Answer on Stackoverflow