[rspec-users] Selecting a date with Webrat

Mike Sassak msassak at gmail.com
Thu Nov 13 13:49:26 EST 2008


I'm writing a scenario that needs to select date values from a form
created with Rails' form_for() method, and I'm looking for a clean way
to do that by specifying only the label (in this case "Date"), rather
than by selecting from each select list one by one.

What I'd like to be able to write is:

When I select "2008-November-13" from "Date"

(or something similar), but this fails because the Date label doesn't
really apply to the individual select_lists. If I write instead

When I select "2008" from "id_from_year_select_1i"

it works, but then I not only need to do that once for each select,
but I need to specify the id, which could change if my model changes.
The first problem could be gotten around by writing a new webrat step
(corresponding to, say, "When I select the date "2008-November-13"
from "Date") but I would still need to specify the ids from each
select. Is there is a better way to do this?


More information about the rspec-users mailing list