So I’m at SDExpo right now, and one of the classes I took was test driven development using Ruby on Rails. This is the point at which I have to make a confession:
I haven’t written a single test for my mystats project.
There, I’m glad I’ve gotten that off my chest. I have two very good excuses so I feel quite justified, but this week the second of those excuses fell:
1) I’m learning a totally new technology and can only learn so many things at once
2) I have no idea how to do unit tests in Rails.
I feel like I’ve started to get my Rails legs now and am transitioning from exploring to implementing, so the first excuse doesn’t hold much water any more either. So now I’ve got to suck it up and go back to write some tests. There are two immediate pieces of work I’m now going to have to go back and redo:
1) Drop my database named ‘mystats’ and create two different ones named ‘mystats_development’ and ‘mystats_test’
2) Throw out my DDL SQL script and replace it with a Rails migration.
I should have known to avoid this hassle, especially because the Rails documentation, books and blogs all took pains to point them out repeatedly, but I was learning so much new stuff that I wanted to stick with something I knew and just move on. I’ve walked away with the lesson reinforced yet again: “when in Ruby/Rails, do as the Rubyists/Railsies do.”