Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding 'safe' frameworks to the preloader #61

Open
jdelStrother opened this issue Jul 27, 2012 · 0 comments
Open

Adding 'safe' frameworks to the preloader #61

jdelStrother opened this issue Jul 27, 2012 · 0 comments

Comments

@jdelStrother
Copy link
Contributor

So now that I've slowed down everyone's test cycles by removing rspec/rails from the preloader (#60), it would probably be a good idea to try to figure out exactly what can be preloaded safely.

Obviously the safest option is not to preload anything - that way you're guaranteed to have the same load ordering as just running via rspec. But on my SSD'd MacPro, I see roughly 1 second wasted every test run due to loading ActiveRecord::Base, ActionController::Base and all their dependencies.

At least for my app, requiring active_record/base & action_controller/base seems safe, and recovers a decent chunk of the time lost by not loading rspec/rails. But to be honest, the rails initialization process and dependency ordering makes my head hurt - I couldn't guarantee it's not going to break stuff, particularly in the face of plugins doing crazy shit. Also, maybe not all apps want to load ActiveRecord?

We could just hand the responsibility off to the user : if they'd like to try to speed things up, they can just add something like the following to .spin.rb :

Spin.hook(:after_preload) do
  require 'action_controller/base'
end

but that seems like a cop-out.

One final option : make rspec/rails safe to load at any time. It seems like maybe rspec could delay some of its loading until the corresponding Rails framework loads - eg in example.rb :

ActiveSupport.on_load(:action_controller) do
  require 'rspec/rails/example/controller_example_group'
end
ActiveSupport.on_load(:action_view) do
  require 'rspec/rails/example/view_example_group'
end

etc. I suspect that leads to a rabbit hole of pain, though.

Any thoughts? Anyone know a particular rails core member who might be able to offer advice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant