Behavior Driven Development in Ruby on Rails

by Melvin Ram

I’ll admit it: I’m not a big fan of testing. I border-line hate it. Why? Mostly because I don’ get it yet and I find that it really doubles or triples the time it takes for me to finish a piece of code. I’ve watched parts of the Peepcode screencasts on testing. I’ve read the testing sections of various books. And I’ve even watched a few of the videos on testing at Best Tech Videos. It still hadn’t sunk in. I mean, I understood the code of it but not the “what’s in it for me?” The usual reasons people give are that you’ll catch broken code as soon as it breaks. Ehh, whatever! I browser test & console test as I write code so I usually know when something is not working as it should. But I hadn’t given up hope! I was knew that it in concept, it’s a good idea and that I just didn’t understand the workflow yet. So I’ve been looking for something/someone to show me HOW  to do it right. And with the help of Rails Envy podcast, I’ve found what I’m looking for… I think. You can get it here: http://www.railsprescriptions.com

I’ve just read the first 31 pages and I’m excited to give Behavior Driven Development a real shot. My first commercial rails project is a webapp called BrainBank. I didn’t have to write tests for the billling & accounts parts because I had bought the Rails SaaS Kit by Ben. The parts I added work as I far as I can tell. I’m probably going to add a few tests for the most critical areas but I’ve console & browser tested it to an Nth degree so I’m not going to spend too much time writing tests  for it. I’m going to launch with the tests I’ve got because I know no one will loose money, die or threaten to kill me/people I know based on what I’ve got in there. 

Here’s what I’m going to do instead:

I’ve got a second commercial project already cooking in my head… so I’m going to solely rely on BDD to build this app… and learn from that experience.

In case it hasn’t been obvious, I recommend you check out Noel Rappin’s (is that really his last name?) ebook and buy his book when it comes out.

{ 2 comments… read them below or add one }

ashleyw February 3, 2009 at 8:47 am

http://www.patchedsoftware.com/RailsEnvy-LoveTests.mov

That was the video which made it finally click; I used to do console/browser testing, but that’s manual, and so I ended up not doing it that often…I’d be testing the part I’m working on, finish — and realize I broke something else!

Testing’s a good way to make sure I’m always working on new/improved features, rather than fixing old ones! :-)

Ruby On Rails Jobs February 25, 2009 at 10:28 am

autotest + shoulda + machinist + forgery absolutely owns! Give it a shot and you won’t look back.

Leave a Comment