Thursday, November 08, 2007

I just got back from RubyConf a few days ago. I was really excited by David Chelimsky's and Dave Astels' talk, 'Behaviour Driven Development with RSpec'. The plain text story runner is a great addition and will be available in the next release which is coming out soon.

In a nutshell, it allows you to create plain-text, executable stories such as:

Story: Daily hour calculation

As a user
I want to be able to enter my time in and time out into my time sheet
So that I can track my hours

Scenario: calculate whole hours
Given a time in of 2007-07-09 19:00
And a time out of 2007-07-09 21:00

Then the hours should be 2

Scenario: 0 minutes is 0 hours
Given a time in of 2007-07-09 19:00
And a time out of 2007-07-09 19:00

Then the hours should be 0

The results of running this story looks like this:
denethor:stories $ruby day.rb
Running 2 scenarios:
Story: Daily hour calculation
As a user
I want to be able to enter my time in and time out into my time sheet
So that I can track my hours


Scenario: calculate whole hours

Given a time in of 2007-07-09 19:00
And a time out of 2007-07-09 21:00

Then the hours should be 2
.
Scenario: 0 minutes is 0 hours

Given a time in of 2007-07-09 19:00
And a time out of 2007-07-09 19:00

Then the hours should be 0
.


2 scenarios: 2 succeeded, 0 failed, 0 pending
A really neat thing is that the output can be saved to a file and executed.

David and Dave presented some really neat ideas around the story runner. One particularly interesting one was the potential of e-mailing to a remote story runner and getting the results e-mailed back. Lots of interesting possibilities lie here.

To get more details, check out David Chelimsky's blog.
Note that at some point the RubyConf talks will be made available online, although I am not sure when and where.

I recommend pulling the latest code from trunk (svn checkout http://rspec.rubyforge.org/svn/) and giving it a spin.