Skip to content
peakpg edited this page Feb 7, 2012 · 3 revisions

A quick reference guide to help to writing step definitions.

Match All

# Scenario
Given a page exists at /some-path
# Step Definition
Given /^a page exists at (.+)$/ do |path|
  @page = Factory(:page, :path=>path)
end

Double Quotes

# Scenario
Given a rails engine named "browsercms" should exist
# Step Definition
Then /^a rails engine named "([^"]*)" should exist$/ do |engine_name|

URLs/Paths

Matches on valid path like characters (which removes the need for double quotes) and allows for words after the path.

# Scenario
Given a page exists at /some-path with:
# Step Definition
Given /^a page exists at ([\/|\w|-]+) with:$/ do |path|
Clone this wiki locally