Ruby On Rails Classroom image

Neha  Jaggi / Professional / Web Technology

To post your Question Join Classroom
Lesson Topics's No:-  |1 | 2 | 3|Last
Lessons:-Signin Tests

Signin Tests

Comparing Figure 8.1 with Figure 7.11, we see that the signin form (or, equivalently, the new session form) is similar in appearance to the signup form, except with two fields (email and password) in place of four. As with the signup form, we can test the signin form by using Capybara to fill in the form values and then click the button.

In the process of writing thetests, we’ll beforced to design aspects of the application, which is one of the nice side effects of test-driven development. We’ll start with invalid signin, as mocked up in Figure 8.2. As seen in Figure 8.2,

when the signin information is invalid we want to re-render the signin page and display an error message. We’ll render the error as a flash message, which we can test for as follows:


it { should have selector  ( 'div.alert.alert-error',  text:  'Invalid') }



(We saw similar code in Listing 7.32 from the exercises in Chapter 7.) Here the selector element (i.e., the tag) we’re looking for is

div. alert. alert - error


Recalling that the dot means ‘‘class’’ in CSS (Section 5.1.2), you might be able to guess that this tests for a div tag with the classes "alert" and "alert-error". We also test that the error message contains the text "Invalid". Putting these together, the test looks for an element of the following form:  

<div  class=  "alert alert-error"  > Invalid... </div>


Neha  Jaggi

Skills    Ruby On Rails

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

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). 


  Students (0)