I was watching Dr Nic's presentation, Dead simple JavaScript Unit
Testing in Rails, which is very good and relevant to anyone who writes
javascript.
http://drnicwilliams.com/2009/11/12/dead-simple-javascript-unit-testing-in-rails/
It got me thinking about the cucumber development rythm (http://
cukes.info):
1. Describe behaviour in plain text
2. Write a step definition
3. Run and watch it fail
4. Write code to make the step pass
5. Run and watch it pass
6. Repeat 2-5 until green like a cuke
7. Repeat 1-6 until the money runs out
So I have setup NGourd in a project so I can get some of this BDD
goodness. An NGourd step definition looks something like:
[Step(@"the page title should be (\w+)")]
public void should_have_title(string pageTitle)
{
NUnit.Framework.Assert.AreEqual(pageTitle, browser.Title);
}
It bothers me that every step definition tends to have duplication
between the text in the regular expression ("the page title should
be") and the method name. I'm thinking that the method name is
syntactic noise that exists because the method must have a name.
Is there a nice syntax that would allow steps to be defined as regular
expressions paired with anonymous methods?