Ruby On Rails Classroom image

Neha  Jaggi / 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
Neha  Jaggi

Skills    Ruby On Rails

Qualifications :- High School - , College/University - Graphic Era Hill University, Dehradun, College/University - ,
Location :-Dehradun,Dehradun,UTTARAKHAND,India
Description:-

Experienced Software Developer with a demonstrated history of working in the Information Technology and services industry. Skilled in Web Technologies (Ruby on Rails, PostgreSQL, php, Laravel and AJAX). 


Explore
 

  Students (0)