Search code examples
ruby-on-railsrubyrspecrspec-rails

Rspec group test ouput


How group some tests to be displayed in a group ?

I launch :

bin/rspec --format=documentation

Actual, I got :

Countries API
  GET /countries
    return list of countries
    returns status code 200
  GET /states/{country_abbrev}
    return list of states
    returns status code 200

Companies API
  GET /companies
    returns companies
    returns status code 200

InvoiceLineRepository
  #create
    create invoice line in database

InvoiceRepository
  #create
    create invoice in database

And I want to have :

  API  
    Countries API
      GET /countries
        return list of countries
        returns status code 200
      GET /states/{country_abbrev}
        return list of states
        returns status code 200

    Companies API
      GET /companies
        returns companies
        returns status code 200

 Repository  
    InvoiceLineRepository
      #create
        create invoice line in database

    InvoiceRepository
      #create
        create invoice in database

The tests that's concern API, are grouped togheter. The tests that's concern Repository, are grouped togheter.

I want this to better organize the visualisation and exploration of my tests

EDIT :

context (see mrzasa response) do not fill my requirements :

Repository
  AddressRepository
    #create
      create address in database

Repository
  AgencyRepository
    #create
      create agency in database

Repository
  ArticleRepository
    #create
      create article in database

Solution

  • You could implement a custom formatter, take a look at the documentation formatter for an example, but as others have said this does not scale, and what exactly is a "group"?