Skip to content

Instantly share code, notes, and snippets.

@oem
Created December 29, 2010 14:01
Show Gist options
  • Save oem/758561 to your computer and use it in GitHub Desktop.
Save oem/758561 to your computer and use it in GitHub Desktop.
capybara date select step definition for cucumber
# capybara step definition for a quick and dirty date select
# For example:
# When I select "May 7, 2010" as the post "published_on" date
When /^I select "([^"]*)" as the (.+) "([^"]*)" date$/ do |date, model, selector|
date = Date.parse(date)
select(date.year.to_s, :from => "#{model}[#{selector}(1i)]")
select(date.strftime("%B"), :from => "#{model}[#{selector}(2i)]")
select(date.day.to_s, :from => "#{model}[#{selector}(3i)]")
end
@worldofchris
Copy link

Thanks, worked like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment