RSpec Generator List

I am looking for a complete list of RSpec generators to easily create specifications for controllers, models, helpers, etc. The only thing I found is:

rails g integration_name

which stores the specification inside the spec / requests folder.

+7
source share
2 answers
  • assistant
  • to establish
  • integration
  • mailer
  • model
  • observer
  • forests
  • view

usage example:

rails g rspec:integration events --> create spec/requests/events_spec.rb 
+13
source

All rspec-rails generators can be found at https://github.com/rspec/rspec-rails/tree/master/lib/generators/rspec You will have to dig a bit in the code to see what they do, but they are well organized, therefore there should not be too much pain.

The generators also have a short readme , which basically says that they start automatically when one of the standard Rails generators starts (rails g user model):

If you type script / rails generate, the only RSpec generator you will actually see rspec: install. This is because RSpec is registered by Rails as a test environment, so whenever you create an application components, such as models, controllers, etc., RSpec specifications are generated and not Test :: Unit.

+3
source

All Articles