Looking at unit tests
I neglected to read the ruby / rails unit test documentation because it seemed cumbersome at first glance. I rolled my own thing for models and assumed controllers would do what they were supposed to do. That worked well enough to get me up and going but tonight I decided I needed something more reliable and rather than reinvent the wheel…..
So I did some reading. The unit tests aren’t as decoupled as I would like them to be (yes Michael Feathers, you have made an impact in my life (his legacy code book is pretty good. I suggest it). I firmly believe that a unit test should not use a database or network. I think you can do that with the model well enough (by avoiding fixtures), but it looks next to impossible for controllers. From what I’ve read testing a controller makes http requests to the web server. I’m not a purist or anything, but its a bummer it has to do that. And I don’t think I can setup an in memory model object for a controller to work with (I’m probably wrong about that, I’d guess there’s some magic) I’d imagine for a full tests suite it would slow things down considerably. The other thing I’m not immediately seeing is a way to sense through a fixture. While not strictly necessary (and may in fact be more trouble than its worth) it sounds like a neat idea. All that said, it looks like the functional testing you can do with the unit test framework is pretty slick. I’m kicking around the idea of setting up some sort of nightly check out / test run just for kicks.
There has been a vanilla crisis in my house ( I think I get cookies!) I’m out.