1

I'm a fan of Rspec, but I never use either controller or view specs. I know the following options exist:

Usage:
  rails generate controller NAME [action action] [options]

Rspec options:
  [--controller-specs], [--no-controller-specs]  # Indicates when to generate controller specs
                                                 # Default: true
  [--view-specs], [--no-view-specs]              # Indicates when to generate view specs
                                                 # Default: true

But is there a way for Rspec to skip on generating these by default? I don't want to be typing --no-controller-specs --no-view-specs every time I generate a controller for instance.

How can I disable spec generation by default? (while keeping some others, eg. models)

Jonathan Allard
  • 18,429
  • 11
  • 54
  • 75

1 Answers1

5

I think you can configure it in application.rb like this:

config.generators do |g|
  g.test_framework :rspec,
    fixtures: true,
    view_specs: false,
    helper_specs: true,
    routing_specs: false,
    controller_specs: false,
    request_specs: true
end 
Doguita
  • 15,403
  • 3
  • 27
  • 36