Comments (9)
Actually.. in addition to having all of spork reload what would be very cool is if we could send arbitrary code (via DRb) to the parent spork process that would be evaluated. That way, we could tell it only to reload certain parts that we know need to be reloaded. Just an idea.. reloading all of it is probably easier to do at this point.
from spork.
This sounds very cool. In order to achieve the "reload specific portions of the app part" we would have to create a few layers of forked processes, similar to how passenger does it. I think having a full restart occur would be a great start and may suffice.
from spork.
I just sent a pull request to both of you with a rough initial reload implementation to take a look at.
This gist: http://gist.github.com/216680 shows how to use the kicker gem to send Drb spec_sever.reload requests when code files change in rails.
from spork.
Hmm ... I just found a much simpler work-around for at least one part of this problem.
Here's a simple description of what I'd like to do:
- Have a rails model and the spec test for that model open in textmate
- command-R in the spec test to see the results
- change code in the model
- command-R again in the spec test to see new results
We are using Factory girl and normally when we run this command to see what is loaded in prefork:
spork -d | grep -A25 models
I see FactoryGirl load all the model classes we are using factories for -- of course by doing that in prefork it means that any model changes I make after spork startup don't appear after the fork.
We added this file: config/initializers/spork.rb
if defined?(Spork)
Spork.trap_class_method(Factory, :find_definitions)
end
reference, Tim's suggestion in this thread: http://groups.google.com/group/sporkgem/browse_thread/thread/24e6342e6629d371#
This delays FactoryGirls loading of the model classes it needs to introspect until after the fork.
My simple test above now works.
My test environment is setup to cache classes (config/environments./test.rb)
config.cache_classes = true
My vendored rails is 2.3.4.
I had thought the model classes would be eagerly loaded in this case but appears not to be the case.
Thinking about how to get the most performance using spork in testing -- obviously the first step is to use more mocks and less factories/fixtures ... but after that a useful generalization is:
- load as many app classes and generate app/state in prefork as possible AND is necessary for your tests
- don't load classes in prefork that you are working on (or app state that might be affected by the change in these classes)
It might be helpful if after Spork started I could add or subtract classes from prefork app state. My method above which reloads the whole prefork is just brute force. If I had kicker watching for fsevents and in the case above removed just the model class I was working on from the prefork -- that might help. I don't know how unloading the class would affect the app state if it already had instances using the earlier versions of the model ...?
from spork.
FYI, RSpactor (0.6.x) handle Spork reload like that: http://github.com/thibaudgg/rspactor/blob/v0.6/lib/rspactor/spork.rb
from spork.
This looks rocking! I will have to investigate. Thanks for pointing it out!
from spork.
I'll certainly refactorize this spork.rb implementation for the 0.7.x version of RSpactor (using IO.popen), but for that I'm waiting for the Rails 3/RSpec 2 compatibility ;-)
from spork.
sigh... it's been a long road. I spent several hours last week just refactoring to make all the tests run with bundler (which is totally awesome and will make it easy for anyone to run the tests). But, it's getting closer :) Closer as in if you're traveling from Spain to New York, you'd be in Portugal right now.
from spork.
Yeah, continue this great works! RSpactor 0.7 with RSpec 2 & Spork support will be super awesome!
from spork.
Related Issues (20)
- save_and_open_page and spork, spork is loosing test suite / output HOT 7
- issue using spork with rails4 HOT 1
- Spork doesn't support custom features/ directory
- spork puts "Done." but didn't finish testing HOT 2
- Is this project still maintained? HOT 2
- With jruby, prefork runs for every test run and makes test slow HOT 3
- Problem with loading file - cannot load such file -- vcr_helper (LoadError)
- Is it possible to tell spork to connect to a DB other than the normal test DB? HOT 1
- No RSpec output HOT 1
- Output has been changed with RSpec 2.99.0.beta1 HOT 3
- Cannot run specific spec (spork runs all specs)
- RSpec + Spork on Win give no output HOT 9
- rails4 rails-observers gem causes observed models to get loaded at startup
- File load times appear to be increasing from when spork was initialized
- rspec-rails 3.0 support? HOT 4
- Cannot run spork with updated Rails4/RSpec3 HOT 6
- Spork / drb shows Connection refused
- spork can't run correctly ,it shows in 'lookup_ring_any' : : RingNotFoundRingNotFound ( RuntimeError() RuntimeError
- warning: assigned but unused variable - method_name_with_spork
- Your Troubleshooting Link is off at Readme
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spork.