Handshake: Design-by-Contract
Handshake, currently in version 0.3.0, is an informal design-by-contract system written by Brian Guthrie in pure Ruby. It's intended to allow Ruby developers to apply simple, clear constraints to their methods and classes.
Handshake is definitely welcome alongside the ever-increasing number of test-driven and behavior-driven design/development based tools, such as RSpec and test/spec.
Some examples of Handshake contracts (from its documentation):
# An array that can never be empty. class NonEmptyArray < Array include Handshake invariant { not empty? } end # An array to which only strings may be added. class NonEmptyStringArray < NonEmptyArray contract :initialize, [[ String ]] => anything contract :<<, String => self contract :+, many?(String) => self contract :each, Block(String => anything) => self end
Visit Handshake project page and Rdoc documentation for more information.