fix regression where date and time fields can no longer be set via String value.

This commit is contained in:
Micah Geisel 2018-09-21 11:43:15 -07:00
parent 54a22f7cb9
commit 443f020cc4
2 changed files with 32 additions and 0 deletions

View File

@ -355,6 +355,10 @@ private
@value = value
end
def to_s
value.to_s
end
def dateable?
!value.is_a?(String) && value.respond_to?(:to_date)
end

View File

@ -84,4 +84,32 @@ RSpec.describe 'Capybara::Session with chrome' do
end
end
end
describe 'filling in Chrome-specific date and time fields with keystrokes' do
let(:datetime) { Time.new(1983, 6, 19, 6, 30) }
before do
@session = TestSessions::Chrome
@session.visit('/form')
end
it 'should fill in a date input with a String' do
@session.fill_in('form_date', with: "06/19/1983")
@session.click_button('awesome')
expect(Date.parse(extract_results(@session)['date'])).to eq datetime.to_date
end
it 'should fill in a time input with a String' do
@session.fill_in('form_time', with: "06:30A")
@session.click_button('awesome')
results = extract_results(@session)['time']
expect(Time.parse(results).strftime('%r')).to eq datetime.strftime('%r')
end
it 'should fill in a datetime input with a String' do
@session.fill_in('form_datetime', with: "06/19/1983\t06:30A")
@session.click_button('awesome')
expect(Time.parse(extract_results(@session)['datetime'])).to eq datetime
end
end
end