Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
93 lines (57 sloc) 2.14 KB

Tryouts v2.0 ALPHA

Put your Ruby tests in comments.

NOTE: Tryouts syntax changed 0.x. The old version is still available in the 0.8-FINAL branch.

Basic syntax

## A very simple test
  1 + 1
#=> 2

## The test description can spread
## across multiple lines. The same
## is true for test definitions.
  a = 'foo' 
  b = 'bar'
  a + b
#=> 'foobar'

## A test will pass when its return
## value equals the expectation. 
#=> String

## The expectations are evaluated.
  1 + 1
#=> 1 + 1

## Here's an example of testing errors
    raise RuntimeError
  rescue RuntimeError
#=> :success

For real world examples, see the Gibbler tryouts.

Setup / Cleanup

All code before the first test definition is assumed to be setup code. All code after the last definition is assumed to be cleanup code. Here is an example:

# This is called after all tests
require 'gibbler'
Gibbler.digest_type = Digest::SHA256

## A Symbol can gibbler
#=> '754f87ca720ec256633a286d9270d68478850b2abd7b0ae65021cb769ae70c08'

# This will be called after all tests
Gibbler.digest_type = Digest::SHA1

Running Tests

Try ships with a command-line tool called try. When called with no arguments, it will look for files ending with _try.rb in the current directory, or in the subfolder try.

You can also supply a specific file to test.

$ try path/2/test.rb

If all tests pass, try exits with a 0. Otherwise it exits with the number of tests that failed.


One of:

$ gem install tryouts


With help from:


This collision was brought to you by Montreal.rb.

Jump to Line
Something went wrong with that request. Please try again.