jeremyw / grand_central forked from Roman2K/rails-test-serving
- Source
- Commits
- Network (8)
- Downloads (6)
- Wiki (1)
- Graphs
-
Branch:
master
tree bff2c49e268f64eb90fb73be60f845e75cfcdf89
parent ca5f7c0d0fd78b9ffbbf004fc7fe02c7038421dc
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Mon Nov 17 22:59:49 -0800 2008 | |
| |
LICENSE | Sat Jan 24 16:46:35 -0800 2009 | |
| |
Manifest | ||
| |
README.mdown | ||
| |
Rakefile | ||
| |
grand_central.gemspec | ||
| |
lib/ | ||
| |
test/ |
GrandCentral
Tired of waiting 10 seconds before your tests run? GrandCentral can make them run almost instantly. This library is described more thoroughly in its introduction article.
Usage
Install the gem:
gem install grand_centralInsert the following lines at the very top of
test/test_helper.rb:require 'rubygems' require 'grand_central' GrandCentral.bootAppend the following line to
~/.bash_profile:
If you get loading errors during the next steps:export RUBYLIB=".:test:$RUBYLIB"- Move the
RUBYLIBline from~/.bash_profileto~/.bash_logininstead. If you are using TextMate, add the following line to the top of test_helper.rb:
$:.reject! { |e| e.include? 'TextMate' }
- Move the
Start the server:
cd <project-dir> ruby test/test_helper.rb --serveRun tests as you usually do:
As a consequence, they work in RubyMate too (⌘R in TextMate).ruby test/unit/account_test.rb ruby test/unit/account_test.rb -n /balance/Have a lot a models and/or mixins? You can reduce reloading time to almost nothing by using
GrandCentralin combination with RailsDevelopmentBoost. Since was originally intended to speed up web-browsing in development mode, be sure to read the note in theREADMEfor how to enable it in test mode.
Note: if the server is not started, tests fall back to running the usual way.
Options
An option hash can be specified for GrandCentral to use, by defining $test_server_options right before require 'grand_central'. It must be a hash with symbol keys. Currently available options are:
reload: An array of regular expressions (or any object responding to===) matching the name of the files that should be forced to reload right after the regular constant cleanup. Note that the constants these files have defined are kept around before being re-require'd.
Example test_helper.rb head:
require 'rubygems'
$test_server_options = { :reload => [/blueprint/] }
require 'grand_central'
GrandCentral.boot
# ...remainder here...
When running tests from the command line, you can bypass the server, forcing tests to be run locally, by passing the --local flag. For example:
ruby test/unit/account_test.rb --local
Caveats
- Tested working with Rails 2.1.2 up to 2.2.2. Compatibility with versions of Rails out of that range is not guaranteed.
- There might exist some quirks: search for "TODO" in the source. I can bear them but contributions are welcome.
- Some unit tests are left to be written.
Credits
Code:
- Roman Le Négrate, a.k.a. Roman2K (contact)
- Jack Chen, a.k.a. chendo
Feedback:
- Justin Ko
- Dr Nic Williams
Released under the MIT license: see the LICENSE file.

