Let's say I have a database to store the data of people (name, email). And there's an update method in the controller. The method is like:
def update
@people = People.find(params[:id])
if @people.update(people_params)
redirect_to people_path
else
render 'edit'
end
end
I wonder how can I test the situation that the update failed? Or do I really need to test it? I have searched it on StackOverflow, there is a link about it, but it not says if I should or should not to test it. Could anyone give me some help about it? If it can be test, how? Thank you so much!
Aucun commentaire:
Enregistrer un commentaire