DEV Community

not-a-patch
not-a-patch

Posted on

Switching off RSpec generators

Finding the correct switch to turn off RSpec generators can be hard as it is sparsely documented. However, RSpec has a number of generators that are listed in this file.

# rspec-rails: lib/generators/rspec/scaffold/scafold_generator.rb
class_option :controller_specs, type: :boolean, default: false, desc: "Generate controller specs"
class_option :request_specs,    type: :boolean, default: true,  desc: "Generate request specs"
class_option :view_specs,       type: :boolean, default: true,  desc: "Generate view specs"
class_option :helper_specs,     type: :boolean, default: true,  desc: "Generate helper specs"
class_option :routing_specs,    type: :boolean, default: true,  desc: "Generate routing specs" 
Enter fullscreen mode Exit fullscreen mode

You can then use the list to switch off generators in application.rb.

config.generators do |g|
  g.test_framework :rspec
  g.controller_specs false
  g.request_specs false
  g.view_specs false
  g.helper_specs false
  g.routing_specs false
end
Enter fullscreen mode Exit fullscreen mode

Top comments (0)