a lightweight random testing tool for Ruby

About RushCheck

RushCheck is a lightweight and automatic specification-based random testing tool for Ruby programs. It is one of implementations of QuickCheck in Haskell .

The programmer provides a specification or assertion of the program in the form of properties which functions or methods should satisfy. Then RushCheck tests the properties hold in a large number of randomly generated testcases. The specifications are written in a block of Ruby, using functions defined in the RushCheck library. RushCheck has some combinators to define properties, guards for pre-condition of the property, some ways for watching the distribution of test data which is randomly generated, and the test data generators. RushCheck can be used also with another testing frameworks Test::Unit or RSpec.

The current status of RushCheck is in alpha stage, and its interface may be changed so often until stable release.

Getting start

There are two ways to install RushCheck.

using gem

You can install RushCheck easily with rubygems

% sudo gem install rushcheck


using setup.rb after download source codes.

Instead, if you don’t have rubygems, or like to install from source codes, then you can follow the steps.

  1. Get the current release from download page
  2. Expand it
  3. ruby setup.rb

See also setup.rb help.


Here is an example for testing with RushCheck.

# sample.rb

# if you have installed RushCheck via RubyGems,
# then you should require files by
 require 'rubygems'
 require_gem 'rushcheck'
rescue LoadError
  # otherwise, if you have installed RushCheck via
  # setup.rb, then
  require 'rushcheck'

# test whether for any integer 'x', [x].sort equals [x].
def ast_sort do |x|
    [x].sort == [x]

# test whether for any integer 'x' and any integer 'y' 
# [x, y].sort equals [x, y], or not.
def ast_sort2, Integer) do |x, y|
    [x, y].sort == [x, y]

Invoke ‘irb’ and test the assertion many times randomly.

% irb -r sample.rb
irb> ast_sort.verbose_check
... (snip) ...
OK, passed 100 tests.
irb> ast_sort2.check
Falsifiable, after 6 tests:
[2, -6]

See also Tutorial[draft] and API references .

Written by Daisuke IKEGAMI
HTML and CSS Design by Nicolas Fafchamps
Generated with Rote and Rog