开发者

writing spec for seeds.rb

开发者 https://www.devze.com 2023-03-08 03:33 出处:网络
In a project, the seeds.rb is getting complicated. We have a seeds/ directory with yml files containing data to be loaded. It should work on re-runs and it should not duplicate records (this is allowe

In a project, the seeds.rb is getting complicated. We have a seeds/ directory with yml files containing data to be loaded. It should work on re-runs and it should not duplicate records (this is allowed in model). Well, the seeds.rb should be tested, it is used to update production. I'm not getting my head around this one though, wondering wether or not to move the开发者_如何学JAVA logic to lib/ and write specs as normal. What would you do?

rails 3 with rspec.


I think you should try out the seed-fu gem:
https://github.com/mbleigh/seed-fu

It doesn't generate duplicate records and can help maintain the consistency of the data.

0

精彩评论

暂无评论...
验证码 换一张
取 消