Skip to content


Subversion checkout URL

You can clone with
Download ZIP
tree: f08f6fe38f
Fetching contributors…

Cannot retrieve contributors at this time

executable file 79 lines (60 sloc) 2.127 kb
Whitestone: simple and succint unit testing
Whitestone is a unit-testing library, a derivative work of Suraj N. Karaputi's
"dfect" (, v2.1 (called "detest" as of v3.0).
Key features:
* terse assertion methods
* arbitrarily nested tests
* colorful and informative console output
* custom assertions
* an excellent test runner
Example of test code, demonstrating many assertions:
D "Person" do
# setup code run just once
D.<< { Person.initialize_tfn_lookup }
# setup code run for each test at this level
D.< { @p ="John", "Smith", 49) }
D "basic methods" do
Eq @p.first_name, "John"
Eq @p.last_name, "Smith"
Eq @p.age, 49
D "graceful error message if badly initialized" do
E(Person::Error) {, 2, 3) }
Mt Whitestone.exception.message, /invalid first name: 1/
D "equality" do
copy = @p.dup
T { copy == @p }
Eq copy, @p # equivalent to above line
D "interactions with system" do
D "tax file number is nil until set" do
N @p.tfn
F { @p.instance_variable_get :resolved_tfn }
T { @p.instance_variable_get :resolved_tfn }
Mt @p.tfn, /\d\d\d-\d\d\d-\d\d\d/
D "address lookup is cached" do
a1 = @p.address
a2 = @p.address
Id a1, a2 # identical
Ko a1, Address
end # "Person"
The assertion methods demonstrated were:
T -- assert true
F -- assert false
N -- assert object is nil
Eq -- assert two objects equal
Mt -- assert string matches regular expression
Id -- assert two objects are identical (same object)
E -- assert error is raised
Ko -- assert an object is kind_of a class/module
Other assertion methods:
Ft -- assert two floats are essentially equal
C -- assert object is thrown
All assertions can be negated by appending an exclamation mark.
See for full details (and screenshots).
Jump to Line
Something went wrong with that request. Please try again.