swt2-intro-exercise / rails-intro-21-rsommerfeld

rails-intro-21-rsommerfeld created by GitHub Classroom
MIT License
0 stars 0 forks source link

New author page should show validation errors #14

Open swt2public opened 3 years ago

swt2public commented 3 years ago

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 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.

Here is the relevant section (5.10) of the Rails Guide.

Error

Expected to find text matching /error/i in "first name\nlast name\nhomepage"

15 exercise tests have passed. There are 44 in total. You will solve multiple at once towards the end.

swt2public commented 3 years ago

Sorry, it's not working for me yet:

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

Error

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!