Created
December 29, 2010 14:01
-
-
Save oem/758561 to your computer and use it in GitHub Desktop.
capybara date select step definition for cucumber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I18n.localize(date, :format => "%B")
If you want to take the locale into account