Ruby On Rails Classroom image

Anil  Bist / 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
Anil  Bist

Skills    Ruby On Rails

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,India
Description:-

I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a
Explore

 

  Students (0)