Bacon – small RSpec clone.

"Truth will sooner come out from error than from confusion."
---Francis Bacon

Bacon is a small RSpec clone weighing less than 350 LoC but nevertheless
providing all essential features.

Whirl-wind tour

require'bacon'describe'A new array'dobeforedo@ary=Array.newendit'should be empty'do@ary.should.be.empty@ary.should.not.include1endit'should have zero size'do@ary.size.should.equal0@ary.size.should.be.close0.1,0.5endit'should raise on trying fetch any index'dolambda{@ary.fetch0}.should.raise(IndexError).message.should.match(/out of array/)# Alternatively:
should.raise(IndexError){@ary.fetch0}endit'should have an object identity'do@ary.should.not.be.same_asArray.newend# Custom assertions are trivial to do, they are lambdas returning a
# boolean vale:
palindrome=lambda{|obj|obj==obj.reverse}it'should be a palindrome'do@ary.should.be.apalindromeendit'should have super powers'doshould.flunk"no super powers found"endend

Now run it:

$ bacon whirlwind.rb
A new array
- should be empty
- should have zero size
- should raise on trying fetch any index
- should have an object identity
- should be a palindrome
- should have super powers [FAILED]
Bacon::Error: no super powers found
./whirlwind.rb:39: A new array - should have super powers
./whirlwind.rb:38
./whirlwind.rb:3
6 specifications (9 requirements), 1 failures, 0 errors

Bacon with autotest

Since version 1.0, there is autotest support. You need to tag your test
directories (test/ or spec/) by creating an .bacon file there. Autotest
then will find it. bin/bacon needs to be in PATH or RUBYPATH.

Converting specs

spec-converter is a simple tool to convert test-unit or dust style tests to
test/spec specs.