4

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

4

2 回答 2

0

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.

于 2013-03-11T21:16:07.087 回答
0

尝试放入ActiveSupport::Dependencies.clearSpork.each_run 块。当你完成对 application_controller.rb 的自动测试后,我会删除它,尽管新的延迟应该不会太糟糕。

于 2011-10-07T19:10:05.053 回答