I want to reuse some Cucumber steps but can't seem to find the right way.
I want to write a step like:
Given /^I login with (.*) credentials$/ |type|
# do stuff with type being one of "invalid" or "valid"
Given /^I login successfully$
# call "Given I login with valid credentials"
UPDATE: The method described below has been deprecated. The recommended way to call a step from within another step now looks like this:
Given /^I login successfully$/ step "I login with valid credentials" end
Old, deprecated method (for reference):
You can call steps from other steps like this:
Given /^I login successfully$/ Given "I login with valid credentials" Then "I should be logged in" end
If all of the scenarios within a feature require this (or other steps), you can also add a Background to each features, with the common steps, like so:
Background: Given I log in with valid credentials Scenario: Change my password Given I am on the account page