O'Reilly logo

Rails 4 Test Prescriptions by Noel Rappin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing Cucumber Steps

Sadly, it’s unrealistic for Cucumber to know what to do just from a step like Given a project. So we must define all the steps so that Cucumber can execute them.

When Cucumber gets a step like Given a project, it searches through all the files in the step definition folder looking for one definition that matches. What does matching mean? Let’s look at the boilerplate for that step again:

 
Given(/^a project$/) ​do
 
pending
 
end

The first line of the definition is one of those Given/When/Then words (it doesn’t matter which one) followed by a regular expression. Cucumber matches a step to a definition when the end of the step, such as a project, matches the regular expression, such as /^a project$/. We’ll see in a little ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required