【发布时间】:2013-03-07 01:10:17
【问题描述】:
我是黄瓜新手,想问一下如何把这段代码干掉(不包含错误):
when /^the user page$/
users_path
when /^the review page$/
reviews_path
我尝试使用正则表达式
when /^the (.+) page$/
$1.to_s+'s_path'
但显然这是错误的。提前致谢!
解决方案(基于aledalgrande 的回答):
when /^the (.+) page$/
send("#{$1}s_path")
【问题讨论】:
标签: ruby-on-rails cucumber dry