Generate only tests from existing model / controllers

前端 未结 3 627
借酒劲吻你
借酒劲吻你 2020-12-31 02:26

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

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-31 03:24

    There's no way to do this that I'm aware of. It would be pretty easy though to just create a temporary rails project and generate scaffolds for all of your models then copy the resulting test directory into the real project.

    I.e.

    rails new temporary
    cd temporary
    rails g scaffold Post title:string body:text
    rails g scaffold Comment post:references author:string body:text
    cp -r test ../real_rails_app/
    

    etc.

    This answer is now out of date. Up to date rails versions allow you to generate only the missing files with the skip option.

提交回复
热议问题