Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate only tests from existing model / controllers

I have a Rails3 app that is based on someone else's work. For some reason they decided not to supply the tests with the app, which I am finding frustrating.

What I want to be able to do is scaffold the tests for all the existing controllers and models so I can get a head start on creating the tests myself in test::unit. I don't want to recreate the models or controllers, just create the tests.

I am new to Rails, and have hunted about for the rake command that might do this, but all with no luck so far. Any advice / direction most appreciated.

like image 906
kelso Avatar asked Dec 06 '10 10:12

kelso


1 Answers

I know it's a little old, but you can do this:

rails g scaffold Post -s

The -s makes it skip the files already created. Also, if you don't use the flag it just asks you if you want to override the file, so, no worries.

like image 157
Zequez Avatar answered Sep 24 '22 04:09

Zequez