-
Notifications
You must be signed in to change notification settings - Fork 202
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
App reloading rails-3.0.0/ruby1.9.2-p0/spork-0.9.0.rc2 #52
Comments
Can you provide a demo application for me to look at where it's not working? The cucumber integration features are all passing, and are specifically testing to make sure that models, controllers, routes, etc. are reloaded with rails. I have no idea why your specs would not be reloaded :) Basically, if your application loads it during boot, then it is not reloaded during the life of spork. So you must organization your application accordingly. Unfortunately, some gems insist on being magical and reaching into your application for you (curses!). In these cases, you must fight black magic with black magic, and use Spork.trap_method and Spork.trap_class_method. |
Well, I'm running sport in a large app. I will try to create a blank rails app and try it again. Btw Using RSpec
by what I understood, everything else not shown here should be auto-reloaded, right? |
Well I doubt you'll run into it with a blank app, because that's exactly what the integration tests do and it works :) See if you can verify when your models are being loaded. At the top of one of your model files, put a `puts caller' statement. Then, send me that stack trace when running spork / specs. Do you see the stacktrace each time you run specs, the first time you run specs, or when starting up the server? |
I have the same issue for a real app running with rails-3.0.0 ree-1.8.7 spork-0.9.0.rc2, here is the stack trace via
|
Ok, realized that bundler was loading spork-0.8.4. After explicitly specifying spork version on |
I've already specified spork version via '>= 0.9.0.rc2'. |
Still having this issue with Rails 3 and Ruby 1.9.2. I'm trying to use steak with spork. It works well, except it doesn't reload my models, and possibly other things I haven't realized. It seems to reload the views fine. Please fix this or give me a hint on where to start! Having to wait 10 seconds for rails 3 to start is really slowing me down! Thanks! |
Want to help? Produce a small rails app (as small as possible) to reproduce this issue. If you look at the cucumber features, spork does work with reloading models, routes, controllers, etc. It has something to do with one of plugins you are using. And I can't reproduce it because I don't know what it is. |
Thanks, I will try to get this for you. Where in Spork is the reload stuff called? |
It isn't called :) The first idea is to prevent it from being loaded it at all. |
Ok, I have a reproducible app. It LOOKS like it has to do with Mongoid. The app is here: http://github.com/bbhoss/spork_bug_example Hope this helps! Let me know if you need anything else. |
@bbhoss: mongoid loads every model on init. It is required to trap this method so it get executed AFTER the fork. AFAICT everything works as expected after doing this. Create a config/initializers/spork_traps.rb if defined?(Spork) Spork.trap_class_method(Rails::Mongoid, :load_models) end |
Sorry for the long wait, this didn't fix it for me. Looks promising though. |
Same issue with routes.rb. Spork cuc dosnt' reload routes.rb |
I've encountered a model reloading problem as well. In my case it has something to do with Machinist. Here is a simple app that demonstrates the problem https://github.com/iast/spork-model-reload-problem-demo . |
Spork can't prevent every unwanted preload, so some work will need to be done by the developer to prevent such occurrences. Some examples on how to solve some common problems are and will be collected here: http://github.com/timcharper/spork/wiki/Spork.trap_method-Jujutsu |
Thanks for the tip. Unfortunately I wasn't able to find which method should be trapped. But thankfully there's other solution that worked for me: I simply prevented Machinist's blueprints.rb file from being loaded in prefork block and am manually loading it in each_run block. |
Hah, ok, yes, that would definitely cause it :) (loading machinist blueprints.rb in the prefork block). I would recommend loading all spec support files in each_run, since its likely you'll want to modify them while you're working on your specs... |
(I'm sorry I didn't see that in your demo app earlier... sigh, I kind of failed you on support there. It has been a crazy time in my life and its taken me 6 mos to get back into the swing of open source again, it seems.) |
I didn't realize that putting blueprints.rb into prefork block can cause such a problem :\ Well, the problem is solved and I can continue enjoying using Spork with my tests and that's what matters :) |
Hello, I'm trying out spork (0.9.0.rc2) with a brand new rails (3.0.0) app. I'm unable to make spork to reload files/classes. Once spork is launched, controllers, models, routes or specs are no longer reloaded. I've read all related issues here and tried all possible workarounds but nothing seems to work. Can you please provide up to date information about the status of reloading?
The text was updated successfully, but these errors were encountered: