README.rdoc

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' do
before do
@ary = Array.new
end
it 'should be empty' do
@ary.should.be.empty
@ary.should.not.include 1
end
it 'should have zero size' do
@ary.size.should.equal 0
@ary.size.should.be.close 0.1, 0.5
end
it 'should raise on trying fetch any index' do
lambda { @ary.fetch 0 }.
should.raise(IndexError).
message.should.match(/out of array/)
# Alternatively:
should.raise(IndexError) { @ary.fetch 0 }
end
it 'should have an object identity' do
@ary.should.not.be.same_as Array.new
end
# 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.a palindrome
end
it 'should have super powers' do
should.flunk "no super powers found"
end
end

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.