Why did my Cucumber script fail with the error "Invalid keys: text, must be one of: text, ..."?

I have the following code to check that the form only accepts date values ​​in the dd-mm-yyyy format. However, I am getting the error

Invalid keys: text must be one of: text ,: visible ,: between ,: count ,: maximum ,: minimum ,: exact ,: match ,: wait

I am assuming this is caused fill_in arg2

in my step definition, but I cannot figure out what is actually wrong.

Functional 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

      

+3


source to share


1 answer


I am assuming the error is in

Then /^I should see failure$/ do
  expect(page).to have_text('div', text: 'prohibited')
end

      

This is not how it is used have_text

. Do either



expect(page).to have_selector('div', text: 'prohibited')

      

or (only if you don't need to check that the text is in a div, which is probably not the case as this is not a very specific selector)

expect(page).to have_text('prohibited')

      

+1


source







All Articles