BDD Stories in RSpec Trunk
Published: October 21st, 2007RSpec, the Behavior Driven Development framework for Ruby is testing the waters with story driven specs. Take a gander at this beautiful development!
I’m just going to simply share my excitement about a developing feature in RSpec1 : writing stories within your specs. Doesn’t this sound like pure bliss? Oh, it is; trust me. Wait, no, don’t trust me, look at the following example from David Chelimsky’s post2 :
Story: transfer to cash account
As a savings account holder
I want to transfer money from my savings account
So that I can get cash easily from an ATM
Scenario: savings account is in credit
Given my savings account balance is 100
Given my cash account balance is 10
When I transfer 20
Then my savings account balance should be 80
Then my cash account balance should be 30
Scenario: savings account is overdrawn
Given my savings account balance is -20
Given my cash account balance is 10
When I transfer 20
Then my savings account balance should be -20
Then my cash account balance should be 10This example was outputted into a text file by ruby script. Did anyone else shed a tear of joy? I hope I’m not the only one…
This feature is still in active development so it’s only available in the trunk of RSpec, but if you want to take a look you can by grabbing the trunk:
svn checkout svn://rubyforge.org/var/svn/rspec/trunk rspec_trunk cd trunk/rspec ruby examples/stories/calculator.rb ruby examples/stories/addition.rb
p.s I hope you’re all BDDing these days, right? ;)

This is beautiful. We have recently started on the path of RSpec/BDD, this is something we’ll be talking about in the morning!
Cheers, love the site design too btw :)
Kee
I will definitely look into this, although I have to say I love Mingle. Maybe there will some way to integrate the two.
Ready. Set. Go.
In terms of the formatting, you're allowed to use markdown, textile, or basic html; it's truly up to you -- what strikes your fancy?
You don't have to worry about your e-mail address being sold to a russian-spam-mafia. I'm only going to use it for my own weird needs; like asking you out for a date on a lonely night of coding.