vendredi 31 juillet 2015

How do I test validations in Rubymine?

Im new to learning Rails and am using Rubymine. Im going through the book RailsSpace and have a question. We created a user model and then created all these validations for when we create new users and it now says to test our validations... However I am not quite sure how to do that. It shows me the code but Im not sure where in Rubymine I can go to test the user validations we made. Help :)

Here's the code it shows the book. From what I understand I need to try and create a new user and give it a username, email, and password... And then it's giving errors on the validations. But where do I create this new user and enter the username, password, and email?

reload!

user = User.new( :screen_name => "me",

?> :password => "a"

?> :email => " ")

=> #"me", "password"=>"a", "email"=>""}>

user.save

=> false

user.errors.on(:screen_name)

=>["is to short (minimum is 4 charaters)", "has already been taken"]

Thanks! C

Aucun commentaire:

Enregistrer un commentaire