| Path: | README |
| Last Update: | Wed Oct 11 18:10:09 EDT 2006 |
SpecUnit is an extension to Test::Unit that allows tests to be grouped into contexts. The idea of contexts comes from rSpec, which is a BDD framework for Ruby. rSpec is a great testing framework, but I built SpecUnit out of the desire to make use of tools already in existence for Test::Unit and to provide a lightweight means of making use of contexts.
To use SpecUnit, simply require ‘spec-unit’
require 'test/unit'
require 'spec-unit'
class TestBlob < Test::Unit::TestCase
include SpecUnit
def setup
@object = Blob.new
end
context 'when empty' do
def specify_should_be_empty
assert @object.empty?
end
end
context 'when has one item' do
def setup
@object.add(2)
end
def specify_has_length_of_one
assert_equal 1, @object.length
end
end
end
As you can see above, contexts can be nested. Setups are run outside in, while teardowns are run inside out. There should be no namespace conflicts as the library is fairly well tested, but let me know if you find any.
I wrote this in a weekend, so there may be some things I didn’t think to test in my tests. Also, there are probably a number of cool features I could add. Let me know if there are any you want, and I’ll consider adding them. Submitting patches makes it much more likely that I’ll implement your feature.
| Author: | Trotter Cashion (trotter@eastmedia.com) |
| Copyright: | Copyright © 2006 Trotter Cashion |
| License: | Distributed under the MIT License |