这是什么问题?尝试将前一作者的代码(使用my)与下面的步骤定义合并。在第一步定义中调用第一步%时,出现以下错误。这个错误是说接收步骤定义是期望两个参数,表和@name是在别处设置的,我只用表user_role值调用它? #FAILS WITH:你的块有2个参数,但Regexp匹配1个参数。
Then I make my person a user with role of "Peak Admin" in Peak
When(/^I make my person a user with role of "([^"]*)" in Peak$/) do |role|
step %{I make my person a user in Peak
| user_role | role | }
end
Then(/^I make my person a user in Peak$/) do |table|
step %{I make the person "#{@name}" a user in Peak
| user_role | table.rows_hash[:user_role] |}
end
When(/I make the person "([^"]*)" a user in Peak$/) do |person,table|
....
答案 0 :(得分:0)
您没有在其他步骤中调用正确获取数据表的步骤 - 请参阅黄瓜维基 - https://github.com/cucumber/cucumber/wiki/Calling-Steps-from-Step-Definitions#calling-steps-with-multiline-step-arguments
接下来,您的第一步就变成了
When(/^I make my person a user with role of "([^"]*)" in Peak$/) do |role|
step "I make my person a user in Peak", table([
[ "user_role", role]
])
end