简体   繁体   中英

Trying to generate rspec test for Controllers

I type:

rails g rspec:controller application

But nothing appears in the spec file?

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.

rails g rspec:integration [name]
  1. controller
  2. helper
  3. install
  4. integration
  5. mailer
  6. model
  7. observer
  8. scaffold
  9. view

example:

 => rails g rspec:integration controller
 => create  spec/requests/controllers_spec.rb

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM