I need to write a cucumber test to test datetime select behavior.
here is my sentence:
When I select “2012-4-30 15:00” as the “start_time”
here is my html view:
= form_tag time_off_requests_path do
= label :time_off_request, :start_time, 'Start Time'
= datetime_select :time_off_request, :start_time , :start_year => Time.current.year, :use_short_month => true
= submit_tag 'Save Changes'
I tried something like
When /^I select “([^”])” as the “([^”])”$/ do |date_time, label|
select(date_time, from => label)
end
but it doesn’t work. get can not find id, name for “select box”
really need help!
The
datetime_selecthelper generates a set of select, not a single form field. You should write a custom step to assign each part of your datetime (day, month, year, hour…) to the corresponding field.