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

Using Aruba’s Ruby DSL

Aruba’s step definitions are a great example of how step definitions should be written. Each of them is hardly ever more than a single line long, delegating all its work to Ruby methods in Aruba’s support layer module Aruba::API. We can call these methods directly from our own step definitions, removing an unnecessary layer of indirection in our code. Here’s how the features/step_definitions/calculator_steps.rb file looks with each of the Aruba step definitions translated to their underlying method calls:

 Given ​/^the input "([^"]*)"$/​ ​do​ |input|
  write_file ​'input.txt'​, input
 end
 When ​/^the calculator is run$/​ ​do
  run ​'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