Pluralisations in features

October 29, 2008

Been a bit of a dummy in this one. Basically each step definition is a regular expression so if we have

When /^I add (\d+) products to the cart$/ do |n|

we can improve this to make allow both

When I add 1 product to the cart
When I add 2 products to the cart

by changing our definition to

When /^I add (\d+) product[s]? to the cart$/ do |n|

In general a good tip is to put step definitions into rubular so we can play and see what will match.

Thanks to Aslak for this