Ruby On Rails Classroom image

prateek  darmwal / Professional / 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
prateek  darmwal

Skills    Ruby On Rails

Qualifications :- High School - S.K.M. Sn. Sec. School, Haldwani, College/University - Graphic Era Hill University, Bhimtal,
Location :-Dehradun,Dehradun,Uttarakhand,India
Description:- I like to explore new technologies. I have skills in ruby on rails, php5, cakephp, jquery, javascript, html/css, java, c & c++. I love coding
Explore
 

  Students (0)