Programming experience
I’m half-way through the second edition of the Agile Web Development with Rails book. I just can’t believe all that Rails does and can do. I’ve been a bad developer so far, in the sense that I haven’t been testing my code using the built-in Rails tests. This is one of the things I didn’t quite get when reading the first edition. To me, it was just more code to write, and I thought the tests were going to be only as good as what I could think of, and if I could think of it I could just test it manually. But that’s a pretty ignorant approach. I think its importance finally hit me when I read about the “story telling” tests. You can take a general statement from the requirements, and implement that as an integration test. It will even follow your redirects. It’s amazing to me. I’m going to mention a couple of things that fascinate me about Rails testing in another post (or two), so I’ll save that jibberish for then.assert_select
Anyway, I’ve been developing for a couple-few years now, and I’m just now learning about testing (or TDD). The point is, I feel like I read a lot about this stuff (programming and web development), as well as maintain my own little projects, and I don’t know half of what it takes to be great. I read about the creator of Ruby on Rails not being a programmer originally, and I just can’t believe he learned to incorporate all of this stuff into a framework, and drive it to work as well as it does. I understand that he’s been in the field for a few years now, but still. I can’t imagine if I were to attempt such a task. I might get as far as abstracting the database, and calling it a day. But it would be leaps and bounds away from how great ActiveRecord is. And that’s not even considering the other things Rails can do. I don’t know, I guess I’m just giving praise. Some people just get it, and they get it quickly. And to be honest, I’m glad they do.

Chris Wednesday, 03 Jan, 2007 Posted at 08:57AM
Instead of TDD, you should check out BDD (behavior driven development) with RSpec. It’s a completely different way of describing your tests, and it’s much cleaner. For example:
context "The rpheath blog" do fixtures :blogs setup do @blog = Blog.find(1) end specify "should have at least one entry" do @blog.should_have_at_least(1).entries end endThat’s a dead simple example of how it works, but the essence is there: the
should_*methods make the whole test environment feel like a simple act of passing messages around and ensuring that they respond properly. I’ve just started building specs for slate, and I’m loving it :-)Ryan Wednesday, 03 Jan, 2007 Posted at 12:24PM
Wow, that’s crazy. If you wouldn’t have mentioned it, I would probably have thought that’s not actual code. I’m anxious to get into that (I’ve yet to get into tests at all). It’s like I don’t know where to start with it. I guess I just need to dive right in. Seeing that, though, gives me more motivation to get cracking. Thanks for the tip.
Chris Thursday, 04 Jan, 2007 Posted at 05:31AM
FYI, I’ve updated tiny (finally!) with some more information on RSpec
Ryan Thursday, 04 Jan, 2007 Posted at 07:08AM
Yeah, I saw that. I didn’t have a chance to comment, as I’m still processing your post. I’m glad people like you figure out what doesn’t work, then tell people like me the steps to get it up and running. Thanks…