Using Devise and Cucumber, and I’ve got the following code for scenarios where the user tries to signup without a password:
Then /^I should see a missing password message$/ do
page.should have_content "Password can't be blank"
end
This is fine when displaying errors at the top of the form, but I have now switched to inline messages, which means that the attribute name is no longer referenced in it’s associated error message, so I need to change my code to this:
Then /^I should see a missing password message$/ do
page.should have_content "can't be blank"
end
Now my features pass, but I’m not 100% happy with this solution. I would feel better if I could also test that this message is attached to the empty password_field, and not just positioned somewhere on the page. I was wondering if there was a way to say something like this:
Then /^I should see a missing password message$/ do
password_field.should have_content "can't be blank"
end
I’m quite new to cucumber.
Check out finding and scoping in the capybara docs: https://github.com/jnicklas/capybara/#finding