Skip to content

Instantly share code, notes, and snippets.

@alg
Created November 15, 2012 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alg/4080472 to your computer and use it in GitHub Desktop.
Save alg/4080472 to your computer and use it in GitHub Desktop.
# Fills the standard Rails 3-field date picker with the date.
# #name# is supposed to lead to one of these fields, either through a label or a CSS selector.
# Usage:
# fill_in_date "Date of birth", with: 30.years.ago
def fill_in_date(name, options)
date = options[:with]
within find_field(name).parent do
find('select[name*="2i"]').select(date.strftime('%B'))
find('select[name*="3i"]').select(date.day.to_s)
find('select[name*="1i"]').select(date.year.to_s)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment