swt2-intro-exercise / rails-exercise-18-NiklasKoehnecke

rails-exercise-18-NiklasKoehnecke created by GitHub Classroom
MIT License
0 stars 0 forks source link

Author should not validate without last name #6

Open swt2public opened 6 years ago

swt2public commented 6 years ago

Scenario

When creating an author without last name Then validation should fail

Hints

Author data should only be added to the system if it reaches a certain quality. Especially, every author should have a last name, that is also not just an empty string. These checks are called 'validations' in Ruby on Rails.

For the tests, the be_valid matcher can be used to test if a model instance passes all validations: expect(@author).to_not be_valid

What do you think is the correct place to test this behavior, is it a model or a feature test?

You can learn about validations in this part of the guide.

Error

Expected #<author id: nil, first_name: "alan", last_name: nil, homepage: "http://example.com", created_at: nil, updated_at: nil> not to be valid

Estimated progress: 38% complete