Given users visit the new author page
And fills in only first name and homepage, and NOT the last name
When they click submit
Then the page should 'error' and what went wrong
Hints
Validation errors should be communicated to the user.
These are stored in the errors attribute of model instances.
It can be checked (@author.errors.any?) and can be iterated over to extract error details (@author.errors.full_messages.each).
Adding this type of code also requires modifying the new action of the AuthorsController.
Your test can try to create an invalid object (on the new author page) and check whether 'error' is displayed.
Scenario
Given users visit the new author page And fills in only first name and homepage, and NOT the last name When they click submit Then the page should 'error' and what went wrong
Hints
Validation errors should be communicated to the user.
These are stored in the
errors
attribute of model instances. It can be checked (@author.errors.any?
) and can be iterated over to extract error details (@author.errors.full_messages.each
). Adding this type of code also requires modifying thenew
action of the AuthorsController.Your test can try to create an invalid object (on the new author page) and check whether 'error' is displayed.
Here is the relevant section of the guide.
Error
15/44 exercise tests have passed