Rails 1.2.1 Impression
I’m updating NearbyGamers to Rails 1.2.1. Nothing broke except my use of assert_tag
in my tests; it’s been long-regarded as squicky and has been replaced with assert_select
. As I’m tidying up some deprecated code, it occurs to me that this makes for an interesting example of how I feel Rails is changing.
Rails is growing inwards and upwards, not just outwards. They’re finding better, terser, more Rails-ish ways to express things. They’re not piling on features, they’re condensing. I’ve mentioned that this is what coding in Rails continually feels like: sometimes it just feels off even though it works and is nicer than other languages, and soon I realize a beautiful Right Way to do it.
Where Rails gained new features, the developers have redesigned functionality to make me think, “Wow, of course, that’s obviously much nicer” and it does more because it’s better-designed. Let me give you an example using assert_tag
.
I’ve got tests that render pages and make sure they contain certain bits of HTML. One test used to be:
` assert_tag :tag => “div”, :attributes => { :id => ‘notice’ }, :child => { :tag => “div”, :content => text } `{lang=”ruby”}
And now it reads:
` assert_select “div#notice > div”, text `{lang=”ruby”}
They rebuilt the assertion to use CSS selectors (with a few clever additions). Suddently the code is simpler, more idiomatic, and more featureful. And that’s just what coding Rails feels like.