O'Reilly logo

The Cucumber Book, 2nd Edition by Steve Tooke, Aslak Hellesoy, Matt Wynne

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

Creating Step Definitions

Without thinking too much about what they mean, let’s just copy and paste the snippets from Cucumber’s last output into a Ruby file. Just like the features, Cucumber is expecting the step definitions to be found in a conventional place:

 $ ​​mkdir​​ ​​features/step_definitions

Now create a Ruby file in features/step_definitions, called calculator_steps.rb. Cucumber won’t mind what you call it as long as it’s a Ruby file, but this is a good name to use. Open it in your text editor and paste in those snippets:

 Given(​/^the input "([^"]*)"$/​) ​do​ |arg1|
  pending ​# express the regexp above with the code you wish you had
 end
 
 When(​/^the calculator ...

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