Ruby on Rails – 4 Days total immersion

We’re half-way through our Geek Retreat, coding Ruby On Rails in an Ayrshire Cottage. A lot of us have been coding / learning rails in near-isolation, so it’s been great to be able to discuss issues and share techniques. Alan’s been writing about it, here for instance.
I’m feeling better about test-driving the controller / view side of things: previously I’ve been uncomfortable with the lack of orthogonality I’ve perceived in the standard functional tests; I’ve started experimenting with a more DSL style. Sneak preview:
when_succesfully_getting(:cities)
the_page_contains_a_table(:a_table) do |t|
t.row "City", "Country"
t.row "Edinburgh", "Scotland"
t.row "Glasgow!!a[href='/buckfast']", "Scotland"
t.row "San Francisco", "USA"
end
there_is_a_form(:new_city) do |f|
f.there_is "input#city_name"
f.there_is "input#city_country"
end

3 Comments:
Nice! I have the same problem with testing controllers and views. Mostly I just minimise the damage by putting as much into the model as possible (which is relatively easy to test) and rely on running through the controllers and views in the browser. Not ideal, and not particularly test-driven, but it's been a reasonable compromise so far.
Have you had a shot of rspec yet?
Thanks. The syntax has moved on a bit - I might try releasing the plugin if it grows a bit more.
No, I haven't tried rspec. I'm not at all sure about the Behaviour Driven Development philosophy. I think Alan summed it all up quite well here.
For things the are particularly tricky or just testing they make it to the browser I'll often switch to using selenium, which hooks into Ruby quite nicely.
Post a Comment
<< Home