This is an experiment for possible faster boot time (and consequently faster feedback) when running tests. I ask your help to try this in your apps (any Rails 3.x app) and let me know how well it works.
Add the following lines inside the configuration block in config/environments/test.rb
:
config.cache_classes = true
def eager_load!; end
Notice that config.cache_classes
needs to be true (which is the default), some tools may not be fine that. Needless to say, just do this for test environments.
The following two benches will work only for rspec running from the command line (hopefully you don't use rake to run your specs):
-
Pick up a spec file that runs all specs under 1s (for example, a file under spec/models or spec/helpers). Run the command below before and after you apply the
eager_load!
patch above (the bigger your application, the faster it should boot after you apply the patch):time rspec spec/models/SOME_MODEL_spec.rb
-
Try running your whole suite with and without the patch. In this case, you shouldn't see any perf difference and everything should work just fine (report if it doesn't!).
Let me know how 1) and 2) goes in the comments section below.
Spec file:
Without patch:
5.30s user 1.28s system 59% cpu 11.151 total
With patch:
4.04s user 0.87s system 80% cpu 6.110 total
Whote suite:
Without patch:
15.04s user 1.60s system 44% cpu 37.148 total
With patch:
13.89s user 1.53s system 51% cpu 29.856 total