Auto-load the seed data from db/seeds.rb with rake

前端 未结 7 1340
谎友^
谎友^ 2020-12-14 08:17

I\'m using rails-rspec gem and I have several specs (models, controllers, etc). When I run:

bundle exec rake

everything is te

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-14 09:08

    Bad idea! Never, ever, seed your test database. Use factories to create, within each test, only the records necessary for that test to pass. Seeding the test database will make your tests less reliable, because you'll be making lots of assumptions that aren't explicitly stated in your tests.

提交回复
热议问题