Search code examples
ruby-on-railstestingruby-on-rails-3rake

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.


Solution

  • 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.