RSpec Formating

August 25th, 2009 0 Comments

Using the -f switch with rspec you can choose several ways to format the output of your test results.  One that I recently found very interesting was

$ spec -fs spec

which will output something similar to this

CustomersController without a logged in user
- should not have access to view a list of customers.
- should have access to view a list of customers.

CustomersController with a user with permissions
- should view a list of customers.
- should view a customer.

The ’s’ format option outputs your specs as a specdoc, describing the behavior of the system under test.

Other formats include:

silent|l                                     : No output
progress|p                              : Text-based progress bar
profile|o                                  : Text-based progress bar with profiling of 10 slowest examples
specdoc|s                                : Code example doc strings
nested|n                                  : Code example doc strings with nested groups indented
html|h                                      : A nice HTML report
failing_examples|e               : Write all failing examples – input for –example
failing_example_groups|g  : Write all failing example groups – input for –example