Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support the case where the first select in a date field is not year (…

…_1i) and the label is attached to the first select - as is done in formtastic
  • Loading branch information...
commit 8367ce9d5e4e15213d5f1bc1b0c7e3878febdcfc 1 parent d7b5a73
@twalpole twalpole authored
View
36 features/select_dates.feature
@@ -57,4 +57,40 @@ Feature: Select dates
"""
1 scenario (1 passed)
6 steps (6 passed)
+ """
+
+ Scenario: Select date when the order of fields is changed and label is set to the first select
+ Given I successfully run `bundle exec rails g scaffold appointment name:string when:date`
+ And I write to "features/create_appointment.feature" with:
+ """
+ Feature: Create appointments
+ Scenario: Constitution on May 17
+ Given I am on the new appointment page
+ And I fill in "Norway's constitution" for "Name"
+ And I select "2009-02-20" as the "When" date
+ And I press "Create Appointment"
+ Then I should see "Norway's constitution"
+ And I should see "2009-02-20"
+ """
+ And I write to "app/views/appointments/_form.html.erb" with:
+ """
+ <%= form_for(@appointment) do |f| %>
+ <div class="field">
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </div>
+ <div class="field">
+ <%= f.label :when, :for => "appointment_when_2i" %><br />
+ <%= f.date_select :when, :order=>[:month, :day, :year] %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+ <% end %>
+ """
+ When I run `bundle exec rake db:migrate cucumber`
+ Then it should pass with:
+ """
+ 1 scenario (1 passed)
+ 6 steps (6 passed)
"""
View
2  lib/cucumber/rails/capybara/select_dates_and_times.rb
@@ -28,7 +28,7 @@ def select_datetime(field, options = {})
# @example "event_starts_at_"
def get_base_dom_id_from_label_tag(field)
- find(:xpath, "//label[contains(., '#{field}')]")['for'].gsub(/(_1i)$/, '')
+ find(:xpath, "//label[contains(., '#{field}')]")['for'].gsub(/(_[1-5]i)$/, '')
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.