Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of RSpec's generators

I'm looking for a comprehensive list of RSpec's generators to easily generate specs for controllers, models, helpers, and so on. The only one I've found is:

rails g integration_test name

that saves a spec inside the spec/requests folder.

like image 698
Mich Dart Avatar asked Jun 16 '12 11:06

Mich Dart


2 Answers

  • controller
  • helper
  • install
  • integration
  • mailer
  • model
  • observer
  • scaffold
  • view

example usage:

rails g rspec:integration events
--> create  spec/requests/events_spec.rb
like image 110
Danny Avatar answered Oct 21 '22 21:10

Danny


All the rspec-rails generators can be found at https://github.com/rspec/rspec-rails/tree/master/lib/generators/rspec You'll have to dig around in the code a little to see what they do, but they are well organized so it shouldn't be too much of a pain.

There's also a short readme on the generators which basically says that they are run automatically when you run one of the standard Rails generators (rails g model User):

If you type script/rails generate, the only RSpec generator you'll actually see is rspec:install. That's because RSpec is registered with Rails as the test framework, so whenever you generate application components like models, controllers, etc, RSpec specs are generated instead of Test::Unit tests.

like image 23
Peter Brown Avatar answered Oct 21 '22 23:10

Peter Brown