I’m spending the summer getting good enough at Rails to fit in at Rails Edge. To do that, I’m creating a website for my kids.
Recently, I plugged in Acts As Authenticated to do signup, login, authentication, and the like. Since I’m messing around with that plugin’s workflow, this seemed like a good opportunity to write workflow tests (which, in Rails, falls under the category of “integration tests”). Here’s my first test, which follows something like the “Even Higher-Level Tests” style in section 13.4 of Agile Web Development With Rails:
dave = new_visitor
dave.starts_at ‘home page’
dave.goes_to ’sign up page’
(dave.is_at ’sign up page’)
dave.enters :login => ‘dave’, :email => ‘firstname.lastname@example.org’,
:password => ‘dave332′, :confirm_password => ‘dave332′
(dave.is_at ‘welcome page’)
# Dave goes away
dave_next_day = new_visitor
dave_next_day.has_clicked_on_link_to ‘confirmation page’, dave.registration_code
(dave_next_day.is_at ‘members page’)
But even as I wrote it, I became discouraged. It’s English-like, yes, but it’s still not terribly skimmable. Answers to questions like “Where do you go after you signup?” don’t leap out at you. Is this really a format that’s going to help people either communicate or make sense of paths through a set of pages?
So I fell back on my ideas about graphical tests and drew the following. (Click the picture for a larger pdf.)
That took longer to draw than it did to write the first test, but actually not a whole lot longer. What do you think? Should I go to the trouble of reimplementing my OmniGraffle parser in Ruby and finish implementing the test? (The good thing about doing that is that it seems like Rails programmers all use Macs, so there’s actually a chance that a test framework I built would get used.)