Force to reload application_controller on each run with Spork
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
.
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.
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.
精彩评论