问题
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