Spinoff will help you to speed up your Ruby test workflow.
It does that by preloading your environment and then using functions like
fork for each run of your test suite to avoid loading framework code
like Rails over and over again. (it supports JRuby as well)
If you are using rails, you probably want to use Spin because it is configuration free.
Lots of code has been taken from the Spin project by Jesse Storimer. Thanks for sharing, Jesse!
Spinoff operates with the assumption that most of the dependencies of your application do not change. If you are working on a Rails project, you probably do not have to reload all Rails classes for each test run.
spinoff-server command starts a server process that will listen for
a list of test files on a unix domain socket. It will also load an init file
which contains all code that should be preloaded.
require 'config/application' for Rails)
spinoff-client command will be called with a list of test files that
should be executed. It sends that file list to the server process via the
unix domain socket.
Once the server process receives a list of files, it will fork the Ruby process and execute the files with the selected test runner. All code that changes frequently will only be loaded in the forked process.
This allows Spinoff to speed up our test suite without any knowledge of the frameworks and libraries we use to build our app.
Spinoff is based on Spin but differs on the following points.
It is framework agnostic and thus needs an init file to preload code. Spin does only support Rails at this time of writing.
It works with JRuby!
It requires configuration.
Spinoff needs an init file to preload code. Please make sure you only load libraries that do not change between your test runs. If you change anything you preload in the init file, you have to restart the Spinoff server.
ENV['RAILS_ENV'] = 'test' require 'config/application' require 'rspec'
Starting the server:
$ spinoff-server --rspec config/spinoff.rb
spinoff-server --help to show all available options.
Sending a list of test files to the server:
$ spinoff-client spec/test1_spec.rb spec/foo/bar_spec.rb
Spinoff should work well with autotest(ish) tools. Just start the server and execute the spinoff client on file changes.
Since JRuby does not support the fork system call, Spinoff is using a
ScriptingContainer for each test run. That also means we cannot really
preload any code. But it saves us from starting a new JVM for each test run.
I'm happy about any kind of feedback and/or contribution.
- New and not well tested.
- No test suite yet.