github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

Roman2K / rails-test-serving

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 55
    • 7
  • Source
  • Commits
  • Network (7)
  • Issues (4)
  • Downloads (6)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (2)
    • master ✓
    • yura
  • Tags (6)
    • v0.1.4.1
    • v0.1.4
    • v0.1.3
    • v0.1.2
    • v0.1.1
    • v0.1.0
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Makes unit tests of a Rails application run instantly — Read more

  cancel

http://roman.flucti.com/a-test-server-for-rails-applications

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

bump gemspec to pick up rails 2.3 fix 
rsanheim (author)
Mon Apr 20 12:43:48 -0700 2009
Roman2K (committer)
Mon Apr 20 13:23:46 -0700 2009
commit  ca5f7c0d0fd78b9ffbbf004fc7fe02c7038421dc
tree    eb4b6d3c4524da59bec395ae699e23ba1a6a86f9
parent  07143f3d2da164d71b75092def264a8ee858a91a
rails-test-serving /
name age
history
message
file .gitignore Mon Nov 17 22:59:49 -0800 2008 ignore manifest [Roman2K]
file LICENSE Sat Jan 24 16:46:35 -0800 2009 unwrapped license paragraphs [Roman2K]
file Manifest Sun Feb 08 05:36:28 -0800 2009 rebuilt both the manifest and the gemspec [Roman2K]
file README.mdown Sat Dec 13 15:54:52 -0800 2008 added a note about the RailsDevelopmentBoost-Ra... [Roman2K]
file Rakefile Mon Apr 20 13:23:46 -0700 2009 bump gemspec to pick up rails 2.3 fix Signed-o... [rsanheim]
directory lib/ Sat Mar 28 10:11:43 -0700 2009 fixed to run under Rails 2.3 [yura]
file rails-test-serving.gemspec Mon Apr 20 13:23:46 -0700 2009 bump gemspec to pick up rails 2.3 fix Signed-o... [rsanheim]
directory test/ Sat Dec 27 11:46:32 -0800 2008 Start listening for test run requests as soon a... [Roman2K]
README.mdown

RailsTestServing

Tired of waiting 10 seconds before your tests run? RailsTestServing can make them run almost instantly. This library is described more thoroughly in its introduction article.

Usage

  1. Install the gem:

    gem install Roman2K-rails-test-serving -s http://gems.github.com
    
  2. Insert the following lines at the very top of test/test_helper.rb:

    require 'rubygems'
    require 'rails_test_serving'
    RailsTestServing.boot
    
  3. Append the following line to ~/.bash_profile:

    export RUBYLIB=".:test:$RUBYLIB"
    
    If you get loading errors during the next steps:
    • Move the RUBYLIB line from ~/.bash_profile to ~/.bash_login instead.
    • If you are using TextMate, you may try to apply this (hopefully temporary) fix.
  4. Start the server:

    cd <project-dir>
    ruby test/test_helper.rb --serve
    
  5. Run tests as you usually do:

    ruby test/unit/account_test.rb
    ruby test/unit/account_test.rb -n /balance/
    
    As a consequence, they work in RubyMate too (⌘R in TextMate).
  6. Have a lot a models and/or mixins? You can reduce reloading time to almost nothing by using RailsTestServing in combination with RailsDevelopmentBoost. Since was originally intended to speed up web-browsing in development mode, be sure to read the note in the README for 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 RailsTestServing to use, by defining $test_server_options right before require 'rails_test_serving'. 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 'rails_test_serving'
RailsTestServing.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.

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server