Skip to content
This repository was archived by the owner on Nov 16, 2018. It is now read-only.

Calling Steps from Step Definitions

aslakhellesoy edited this page Aug 13, 2010 · 23 revisions

It is possible to call steps from step definitions:

Given /^A user (.*) exists$/ do |name|
  # ...
end

Given /^I log in as (.*)$/ do |name|
  # ...
end

Given /^(.*) is logged in$/ do |name|
  Given "A user #{name} exists"
  Given "I log in as #{name}"
end

This is pracical if you have several common steps that you want to perform in several scenarios. This allows you to do this in a Scenario:

Scenario: View last incidents Given Linda is logged in # This will in fact invoke 2 step definitions

Clone this wiki locally