Put your Ruby tests in comments.
NOTE: Tryouts syntax changed 0.x. The old version is still available in the 0.8-FINAL branch.
## 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. 'foo'.class #=> String ## The expectations are evaluated. 1 + 1 #=> 1 + 1 ## Here's an example of testing errors begin raise RuntimeError rescue RuntimeError :success end #=> :success
For real world examples, see the Gibbler tryouts.
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 :anything.gibbler #=> '754f87ca720ec256633a286d9270d68478850b2abd7b0ae65021cb769ae70c08' # This will be called after all tests Gibbler.digest_type = Digest::SHA1
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:
-
Syntenic for the hackfest venue.
This collision was brought to you by Montreal.rb.