导轨中的多个夹具组?
有没有办法为 Rails 测试提供不同的夹具集(您可能称之为“夹具配置文件”)?
我发现的最好的插件是 2006 年的 Rails 1.3 插件。我以为这样的东西会有更多的需求。就我而言,我想要一个“离线”配置文件,其中包括所有数据的缓存,以及另一个获取数据所需的“在线”配置文件。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于没有人回答,我会说这里最好的解决方案似乎是 Factory女孩。它不是内置的 Rails 固定装置,但它确实是固定装置的增强版本,并且支持本问题中的用例。固定装置的问题在于它们将固定装置文件与类紧密联系在一起。但对于 Factory Girl,您可以拥有任意数量的工厂定义。
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.