Ruby Flare

Your awesome Tagline

0 notes

Calling cucumber steps with tables

You can easily call other cucumber steps from within other steps. This makes it easy to reuse step definitions.

Then /^no users should exist$/ do
  Then "0 users should exist"
end

To do this with a cucumber step that takes a table or a multiline string, just pass the table or string as the second argument for the step:

Given /^the following users have been assigned to the group$/ do |table|
  Given "the following users exist:", table
  # do other stuff to assign them to the group
end

Given /^the following csv file$/ do |pystring|
  Given "a file exists with the following:", pystring
end

There’s more ways of nesting steps so do check out the info on the Cucumber wiki.

Filed under cucumber