test/spec is BDD interface for Test::Unit. I got chance to use it for TaskBin. I found that writing tests using BDD is more fun than Test::Unit tests. Check this link for detailed test/spec explanation which was an announcement for test/spec 0.3.

BDD is the way of writing code by testing what the code should do, rather than testing the code itself. BDD = Behavior driven development.

Previously, I used to do TDD using Test::Unit which comes inbuilt with Ruby and fully supported in Rails. Christian Neukirchen ( of Anarchaia fame) wrote test/spec. Great work! I am very much excited to use test/spec further in my projects.

RSpec is also a very popular framework. But I have not explored it well and also, I wanted to do BDD, without losing/affecting my existing tests i.e. Test:Unit tests. That’s why I chose test/spec, which allows me to write BDD tests without affecting my previous Test::Unit tests.

Following are some links which will help you to understand BDD in more detail.

http://errtheblog.com/post/4268 BE DEE DEE AND ME.

http://rspec.rubyforge.org/ Rspec site, detail explanation about using Rspec

Nice article telling how to use BDD for rails model.

To install test/spec you just have to type

c:gem install test-spec

…on Windows

$sudo gem install test-spec

…on Linux and variants

and in your test_helper.rb or in your test file, add this line

require 'test/spec'

That’s it, you can now write your BDDed tests in your old test files under unit/functional/integration tests.