I have the following code to verify that a form only accepts date values in dd-mm-yyyy format. However, I get the error
Invalid keys :text, should be one of :text, :visible, :between, :count, :maximum, :minimum, :exact, :match, :wait
I presume this is caused by fill_in arg2
in my step sefinition, but I can't figure out what is actually wrong.
Feature file:
Scenario Outline: Edit Person Validation
Given I login
And I edit a person
When I enter <value> as <field>
Then I should see <validity>
Scenarios: valid
| value | field | validity |
| 20-05-2014 | person_startdate | success |
| JA-61-47-66-C | person_nino | success |
Scenarios: invalid
| value | field | validity |
| 05-20-2014 | person_startdate | failure |
| 2014-05-20 | person_startdate | failure |
| 2014-20-05 | person_startdate | failure |
| 20/05/2014 | person_startdate | failure |
| 20-05/2014 | person_startdate | failure |
| 20/05-2014 | person_startdate | failure |
| 20/05-2014 | person_startdate | failure |
| 20'05'2014 | person_startdate | failure |
| Today | person_startdate | failure |
| Tomorrow | person_startdate | failure |
| 2014 | person_startdate | failure |
| March | person_startdate | failure |
| 05-20 | person_startdate | failure |
| JH-22-43-61 | person_nino | failure |
Step definition:
Given /^I login$/ do
login "*****", "*****"
end
Given /^I edit a person$/ do
visit edit_person_path('1682')
end
When /^I enter (.+) as (.+)$/ do |arg1,arg2|
fill_in arg2, with: arg1
click_on 'Save'
end
Then /^I should see failure$/ do
expect(page).to have_text('div', text: 'prohibited')
end
Then /^I should see success$/ do
expect(page).to have_selector('h1', text: 'Your People')
end
def login(username, password)
visit login_path
@user = User.create(username: username, password: password)
fill_in "username_or_email", with: @user.username
fill_in "login_password", with: @user.password
click_on "Log In"
end