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:-Testing a Title Change

This uses the have_selector method, which checks for an HTML element (the ‘‘selector’’) with the given content. In other words, the code

 

checks to see that the content inside the title tag is  

"Ruby on Rails Tutorial Sample App | Home"

 

(We’ll learn in Section 4.3.3 that the :text => "..." syntax is a hash using a symbol as the key.) It’s worth mentioning that the content need not be an exact match; any substring works as well, so that  

page.should have selector(  'title',  :text =>  " | Home" ) 

   

    will also match the full title.

Note that in Listing 3.17 we’ve broken the material inside have_selector into two lines; this tells you something important about Ruby syntax: Ruby doesn’t care about newlines.11 The reason I chose to break the code into pieces is that I prefer to keep lines of source code under 80 characters for legibility.12 As it stands, this code formatting is still rather ugly; Section 3.5 has a refactoring exercise that makes them prettier, and Section 5.3.4 completely rewrites the StaticPages tests to take advantage of the latest features in RSpec.

         Adding new tests for each of our three static pages, following the model of Listing 3.17, gives us our new StaticPages test (Listing 3.18).

 
 
 
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)