Browse files

update docs

  • Loading branch information...
1 parent 4daf6aa commit bd96de29eaa412779d180e0fbc054e155464d8c7 @geemus geemus committed Jan 25, 2011
Showing with 48 additions and 5 deletions.
  1. +48 −5 README.rdoc
View
53 README.rdoc
@@ -18,29 +18,72 @@ Returns takes what you expect and checks a block to see if the return value matc
Raises takes what error you expect and checks to see if the block will raise it:
Shindo.tests do
- raises(StandardError) { StandardError.new }
+ raises(StandardError) { raise StandardError.new }
end
+For one off simple tests like this you can also chain the calls like this:
+
+ Shindo.tests('raises').raises(StandardError) { raise StandardError.new }
+
You can also override the default descriptions:
Shindo.tests('foo/bar') do
returns('foo', 'returns foo when bar') { 'foo' }
- returns('bar', 'returns bar when qux') { 'bar' }
+ raises(StandardError, 'raises StandardError when baz') { raise StandardError }
+ end
+
+Or nest things inside tests blocks:
+ Shindo.tests do
+ tests('returns') do
+ returns('foo', 'returns foo when bar') { 'foo' }
+ returns('bar', 'returns bar when baz') { 'bar' }
+ end
+ tests('raises') do
+ raises(StandardError, 'raises StandardError when baz') { raise StandardError }
+ raises(StandardError, 'raises StandardError when qux') { raise StandardError }
+ end
end
Then, if you want to get real fancy you can also tag your tests, to help narrow down which ones to run
Shindo.tests('tests for foo', 'foo') do
- test('foo') { true }
+ test('foo') { true }
end
Shindo.tests('tests for bar', 'bar') do
- test('bar') { true }
- end
+ test('bar') { true }
end
Note: you'll have to supply a non-default description first, and then follow up with tags.
+== Setup and Teardown
+
+Tests get evaluated in the file just like you see it so you can add setup and teardown easily:
+
+ Shindo.tests do
+ foo = 'bar' # setup
+ tests('foo').returns('bar') { foo }
+
+ foo = 'baz' # cleanup after last
+ tests('foo').returns('baz') { foo }
+
+ foo = nil # teardown
+ end
+
+That can get pretty tedious if it needs to happen before or after every single test though, so there are helpers:
+
+ Shindo.tests do
+ before do
+ @object = Object.new
+ end
+
+ after do
+ @object = nil
+ end
+
+ tests('@object.class').returns(Object) { @object.class }
+ end
+
== Running tests
Run tests with the shindo command, the easiest is to specify a file name:

0 comments on commit bd96de2

Please sign in to comment.