Ruby On Rails Classroom image

prateek  darmwal / Professional / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2 | 3|Last
Lessons:-Features and Steps

In this context, it’s worth noting that, like RSpec, Cucumber can be invoked using a Rake task:

bundle exec rake cucumber

 

(For reasons that escape me, this is sometimes written as rake cucumber:ok.)

All we’ve done so far is write some plain text, so it shouldn’t be surprising that the Cucumber scenarios aren’t yet passing. To get the test suite to green, we need to add a step file that maps the plain-text lines to Ruby code. The step file goes in the features/step_definitions directory; we’ll call it authentication_steps.rb.

     The Feature and Scenario lines are mainly for documentation, but each of the other lines needs some corresponding Ruby. For example, the line  

Given  a user visits the signin page

 

in the feature file gets handled by the step definition

 Given  /ˆa  user  visits   the signin  page$/  do
    visit signin path
end

 

In the feature, Given is just a string, but in the step file Given is a method that takes a regular expression and a block. The regex matches the text of the line in the scenario, and the contents of the block are the Ruby code needed to implement the step. In this case, ‘‘a user visits the signin page’’ is implemented by  

visit  signin  path

 

If this looks familiar, it should: It’s just Capybara, which is included by default in Cucumber step files. The next two lines should also look familiar; the scenario steps

When   he submits invalid signin information
Then   he should see an error message 

 

in the feature file are handled by these steps:

When /ˆhe submits invalid signin information$/  do
    click button   "Sign in"
end
Then /ˆhe should see an error message$/  do
     page.should have selector ( 'div.alert.alert-error' )
end
 
 
 
image
prateek  darmwal

Skills    Ruby On Rails

Qualifications :- High School - S.K.M. Sn. Sec. School, Haldwani, College/University - Graphic Era Hill University, Bhimtal,
Location :-Dehradun,Dehradun,Uttarakhand,India
Description:- I like to explore new technologies. I have skills in ruby on rails, php5, cakephp, jquery, javascript, html/css, java, c & c++. I love coding
Explore
 

  Students (0)