每次使用 Spork 运行时强制重新加载 application_controller

发布于 2024-11-07 00:18:14 字数 178 浏览 3 评论 0原文

我正在使用 Spork 来加速我的 RSpec 测试。不幸的是,我的 application_controller.rb 在每次运行时都没有重新加载,因此我在修改它时必须重新启动 Spork。有没有办法在每次测试运行时强制重新加载?我想我需要在 Spork.each_run 中添加一些行。

I am using Spork to speed up my RSpec tests. Unfortunately my application_controller.rb gets not reloaded on each run so that I have to restart Spork when modifying it. Is there a way to force a reload on each test run? I guess I need some additional line in Spork.each_run.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你又不是我 2024-11-14 00:18:14

尝试将 ActiveSupport::Dependency.clear 放入 Spork.each_run 块中。当您完成自动测试 application_controller.rb 后,我会删除它,尽管新的延迟应该不会太糟糕。

Try putting ActiveSupport::Dependencies.clear into the Spork.each_run block. I would then remove this when you're done autotesting application_controller.rb, although the new delay shouldn't be too bad.

白首有我共你 2024-11-14 00:18:14

I had the same issue, but Spork is designed to automatically reload application_controller.rb without changes. So I dug into it and as mentioned in a comment in this blog post I ran spork --diagnose. It lists all of the files initially loaded by spork and the backtrace for how each file was loaded. This showed me that in my app I happened to have an initializer that was referencing a subclass of ApplicationController and thus it was getting loading initially. Once I broke that dependency my application_controller.rb started reloading correctly on each test run when using Spork.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文