Ruby On Rails Classroom image

prateek  darmwal / Professional / Web Technology

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

 

The initial validation tests then appear as in Listing 6.11.

 

The first new example is just a sanity check, verifying that the @user object is initially valid:

it { should be valid }

 

This is another example of the RSpec boolean convention we saw in Section 6.2.1: Whenever an object responds to a boolean method foo?, there is a corresponding test method called be_foo. In this case, we can test the result of calling

@ user .valid ?

 

with

@ user. should  be  valid  

 

  As before, subject { @user } lets us leave off @user, yielding it { should be valid }

it  { should  be  valid }

 

The second test first sets the user’s name to an invalid (blank) value, and then tests to see that the resulting @user object is invalid:

describe  "when name is not present"  do
         before { @user .name  =  " "  }
         it { should not be valid }
end
 
 
 
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)