Ruby On Rails Classroom image

Pooja  Negi / Student / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2 | 3|
Lessons:-Validating Presence

This uses a before block to set the user’s name to an invalid (blank) value and then checks that the resulting user object is not valid.
               You should verify that the tests fail at this point:

 

$ bundle exec rspec spec/models/user spec.rb
...F
4 examples, 1 failure

 

Now uncomment the validation (i.e., revert Listing 6.10 back to Listing 6.9) to get the tests to pass: 

$ bundle exec rspec spec/models/user spec.rb
. . .
 4  examples, 0 failures

 

Of course, we also want to validate the presence of email addresses. The test (Listing 6.12) is analogous to the one for the name attribute.

 

The implementation is also virtually the same, as seen in Listing 6.13.

________________________________________________________________________________________

 

Now all the tests should pass, and the presence validations are complete.

 
 
 
image
Pooja   Negi

Skills    Ruby On Rails

Qualifications :- High School - SSN high school, College/University - HNBGU, College/University - SRHU,
Location :-Ranipokhari,Rishikesh,Uttarakhand,India
Description:- Student
Explore
 

  Students (0)