Starting from scratch, I've tried following the mantra "write no code unless a test fails." This left me writing tests such as this one:
def test_create_duplicate_feedThis test allowed me to write one line of code in the model:
feed_a = Feed.new(:url => "http://feeds.joystiq.com/weblogsinc/joystiq")
feed_b = Feed.new(:url => "http://feeds.joystiq.com/weblogsinc/joystiq")
feed_a.save
assert !feed_b.save
end
validates_uniqueness_of :urlNeedless to say it was a little slow and frustrating at the start. Since then I've adjusted the mantra and am now just coding the easy, boring stuff and using intermittent TDD for interesting stuff. I do keep away from generating generic scaffolds inside the project, as that creates tons of unnecessary code. This mix of quasi-TDD and avoiding the generate command has tidied up my code a great deal and made iterative development much easier.
No comments:
Post a Comment