Ruby On Rails Classroom image

Pooja  Negi / Student / Web Technology

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

                                  

 

This code looks nicer, but the title test is still a bit long. Indeed, most of the title tests in Listing 5.20 have long title text of the form

"Ruby  on  Rails  Tutorial  Sample  App  |  About"

 

An exercise in Section 3.5 proposes eliminating some of this duplication by defining a base_title variable and using string interpolation (Listing 3.30). We can do even better by defining a full_title, which parallels the full_title helper from Listing 4.2. We do this by creating both a spec/support directory and a utilities.rb file for RSpec utilities (Listing 5.26).  

 

                          

 

Of course, this is essentially a duplicate of the helper in Listing 4.2, but having two independent methods allows us to catch any typos in the base title. This is dubious design though, and a better (slightly more advanced) approach, which tests the original full_title helper directly, appears in the exercises (Section 5.6).  Files in the spec/support directory are automatically included by RSpec, which means that we can write the Home tests as follows:

 

              

 

We can now simplify the tests for the Help, About, and Contact pages using the same methods used for the Home page. The results appear in Listing 5.27.

 

                             

 
 
 
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)