Open swt2public opened 3 years ago
Sorry, it's not working for me yet:
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
Expected to find text matching /error/i in "first name\nlast name\nlast name can't be blank\nlast name is too short (minimum is 1 character)\nhomepage"
If you have problems solving this task, please don't hesitate to contact the teaching team!
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 (5.10) of the Rails Guide.
Error
15 exercise tests have passed. There are 44 in total. You will solve multiple at once towards the end.