Reuse Cucumber steps

Note that the method for calling steps within steps has changed in recent versions of cucumber, which you’ll see if you get an error like “WARNING: Using ‘Given/When/Then’ in step definitions is deprecated, use ‘step’ to call other steps instead:/path/to/step_definitions/foo_steps.rb:631:in `block in ‘
“. See the cucumber wiki for details.

The gist of the change is that you should now use the step or steps methods.

When /^I make all my stuff shiny$/
  step "I polish my first thing"
end

When /^I make all my stuff shiny$/
  steps %Q{
    When I polish my first thing
    When I shine my second thing
  }
end

Leave a Comment