Spork Capybara,config.cache_classes冲突
我正在尝试使用 TestUnit 设置 Spork 和 Capybara,并且正在运行 陷入 test.rb 配置问题。
问题是 Spork 要求 config.cache_classes 设置为 false,以便模型中的更改可以 运行测试时会得到反映,而无需重置 Spork 所有 时间。
另一方面,水豚似乎需要 config.cache_classes 设置为 true,否则集成测试 只是似乎不起作用。
我只是在寻找任何可能的解决方案/解释。是 这仅存在于 TestUnit 中,或者这可能是 bug,我应该这样报告它吗?任何帮助都会很大 赞赏!
I'm trying to setup Spork and Capybara with TestUnit, and am running
into a test.rb config problem.
The issue is that Spork requires that
config.cache_classes be set to false, so that changes in the model can
be reflected when running tests without having to reset Spork all the
time.
Capybara, on the other hand, seems to require that
config.cache_classes be set to true, otherwise the integration tests
just don't seem to work.
I'm just looking for any possible solution / explanation for this. Is
this something that only exists within TestUnit, or is this perhaps a
bug and I should report it as such? Any help would be greatly
appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议采取类似于this 一。您要做的主要事情是将您的 config.cache_classes 设置为 true,但强制 Spork 在每次运行时重新加载您的模型和依赖项:
希望这将使 cache_classes 对于 Capybara 为 true,但它也将允许您的模型并在测试运行之间重新加载观察者。
I would recommend taking an approach similar to this one. The main thing you'll want to do is set your config.cache_classes to true, but force Spork to reload your models and dependencies on each run:
Hopefully this will allow the cache_classes to be true for Capybara, but it will also allow your models and observers to be reloaded between test runs.
我在叉勺和黄瓜上遇到了类似的问题。我找到的解决方案是:
spork设置DRB环境。我不认为这是解决这个问题的最优雅的方法,但是如果水豚设置了一些环境变量,你可以使用它吗?
I ran into a similar issue with spork and cucumber. The solution I found was :
spork sets the DRB environment. I dont think this is the most elegant way to solve this, but if capybara sets some env variable, you could use that ?