I used jatin's answer, but have a separate step:
When /^(.*) within ([^:]+)$/ do |step, parent|
with_scope(parent) { When step }
end
Then /^"([^\"]*)" should link to "([^\"]*)"$/ do |link_text, page_name|
URI.parse(page.find_link(link_text)['href']).path.should == path_to(page_name)
end
Then I have this in my test:
step '"my foods" should link to "food_histories" within ".tabs"'
And this is on my roads:
def path_to(page_name)
case page_name
when /^food_histories$/
food_histories_path
end
end
source
share