If you noticed spork startup getting slower when switching to Rails 2.3, your not alone 😉
- Views are eager loaded
- app/ is eager loaded (when config.cache_classes is on)
Without hack: 18s startup
With hack: 2s startup 😀
Try it
#spec/spec_helper.rb require 'spork/app_framework/rails' Spork::AppFramework::Rails::NinjaPatcher.class_eval do # views are preloaded spork must be restarted for view changes def delay_eager_view_loading puts "removed because i am too slow..." end # do not preload application files # alternatively urn off config.cache_classes def delay_app_preload ::Rails::Initializer.send(:define_method, :load_application_classes){} end end Spork.prefork do ...
Or… you could set config.cache_classes = false (the responsible config setting that invoked eager loading).
Tim
yes, this works as replacement for the second hack, ill add it to the instructions, thanks
Hello
That delay_app_preload method fixed cucumber preloading issue when cache_classes = true..
However, that delay view logic has view can’t be reloaded problem..
thx for sharing
Thank you for this hack. Saved a lot of time!!
Hello there! After more than 3 years, we still use Rails 2.3, and I was trying to use this nice trick but…the
require ‘spork/app_framework/rails’
line is making spork upset…
no such file to load — spork/app_framework/rails (LoadError)
so I tried to remove it. It works, but I don’t see any changes in the speed. It’s still around 10 seconds loading…any clue about this?
Many thanks!
Updated the code, to explode when the class is not there,
my guess would be that either the module is no longer there or the methods got renamed, check out an older version of spork, or dig through the spork repo to find what it is called nowadays