How to select date from a select box using Capybara in Rails 3?

后端 未结 11 1507
梦如初夏
梦如初夏 2020-12-05 10:27

I\'m writing a spec for a controller in Rails 3 project using RSpec and Capybara, and I want to select current date from a select box. I tried:

select Date.t         


        
11条回答
  •  清歌不尽
    2020-12-05 11:09

    For Rails 4, in case somebody gets to this question without being limited to Rails 3.

      select '2020',  from: 'field_name_{}_1i'
      select 'January',  from: 'field_name_{}_2i'
      select '1', from: 'field_name_{}_3i'
    

    You can of course extract this to a helper and make it dynamic.

提交回复
热议问题