CITcon 2007: RSpec is the new Test::Unit

Eric PughApril 28, 2007

My first session was entitled RSpec is great of what? and talked about a tool that helps you do “Behavior Driven Development”. The key difference between RSpec as a validation tool from other xUnit tools like JUnit or Test::Unit is that instead of using “Assert” style validations we use “Should” style validations. Here is a short example of pulling up a web page and verifying the words “Administer Bookshelf” show up.

$ie = $ie || Watir::IE.new $ie.goto http://localhost:3000/login/login $ie.text.should include(Administer Bookshelf)

Compare the last line to something in the older “Assert” style:

assert $ie.text.include?(`Adminster Bookshelf)

The should syntax reads much easier! And by removing the word “test” from your vocabulary you remove the Tester/Developer divide. “Should” is something you would define before writing the code. “Test” is something you do after you write the code!


More blog articles:


We empower great search teams!

We help teams that use Solr and Elasticsearch become more capable through consulting and training.

Services Training