Ruby On Rails Classroom image

Anil  Bist / Professional / Web Technology

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

Pretty RSpec

 

We noted in Section 5.3.1 that the tests for the static pages are getting a little verbose and repetitive (Listing 5.20). In this section we’ll make use of the latest features of RSpec to make our tests more compact and elegant. Let’s take a look at a couple of the examples to see how they can be improved:

 

describe   "Home page"   do
      it       "should  have  the  h1  'Sample App'"    do
        visit root path
        page. should  have  selector  (  'h1' ,  text:  'Sample App ')
end

 

                       

 

One thing we notice is that all three examples include a visit to the root path. We can eliminate this duplication with a before block:

 

         

 

This uses the line

before   { visit  root  path  }

 

to visit the root path before each example. (The before method can also be invoked with before(:each), which is a synonym.)

                Another source of duplication appears in each example; we have both

 

it   "should have the h1 'Sample App'"   do
 
 
 
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)