Tryouts v2.4 (2024-07-20)
Ruby tests that read like documentation.
A simple test framework for Ruby code that uses introspection to allow defining checks in comments.
Installation
One of:
- In your Gemfile:
gem 'tryouts'
- As a gem:
gem install tryouts
- From source:
$ git clone git://github.com/tryouts/tryouts.git
Usage
$ try
$ try try/10_utils_try.rb
$ try -h
Usage: try [options]
-V, --version Display the version
-q, --quiet Run in quiet mode
-v, --verbose Run in verbose mode
-f, --fails Show only failing tryouts
-D, --debug Run in debug mode
-h, --help Display this help
Exit codes
When all tests pass, try exits with a 0. An exit code of 1 or more indicates the number of failing tests.
Writing tests
1 + 1
a = 'foo'
b = 'bar'
a + b
'foo'.class
81
begin
raise RuntimeError
rescue RuntimeError
:success
end
For real world examples, see Onetimesecret tryouts.
Test setup / cleanup
Put the setup code at the top of the file, and cleanup code at the bottom. Like this:
require 'gibbler'
Gibbler.digest_type = Digest::SHA256
:anything.gibbler
Gibbler.digest_type = Digest::SHA1
__
Thanks
This collision was brought to you by Montreal.rb.