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?
I would use Time.parse to convert the string from the scenario to feed
it into the helper. In my particular case the id prefix could be
inferred easily from th the step, but your case might be different.
That should hopefully get you started though.
to do that by specifying only the label (in this case “Date”), rather
rspec-users mailing list
selects time.day, :from => “#{id_prefix}_3i”
Or better yet - add it to webrat proper and ask Bryan to pull it.
(It’s rails specific, so it should only be in the rails part of
webrat).
Aslak
Good idea, guys! And yes, I can take a hint. Here is what I was
able to get done tonight: