Multiple Fixture Sets in Rails?

自闭症网瘾萝莉.ら 提交于 2020-01-03 08:37:10

问题


Is there a way to have different fixture sets (what you might call a "fixture profile") for Rails tests?

The best I've found is a Rails 1.3 plugin from 2006. I thought there'd be more demand for this kind of thing. In my case, I want an "offline" profile which would include a cache of all data, and another "online" profile which would be required to fetch data.


回答1:


Since no-one's answered, I'll say that the best solution here seems to be Factory Girl. It's not built-in Rails fixtures, but it's really an enhanced version of fixtures, and one which supports the use case in this question. The problem with fixtures is they closely tie the fixture file to the class. But with factory girl, you can have as many factory definitions as you like.



来源:https://stackoverflow.com/questions/7894781/multiple-fixture-sets-in-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!