【发布时间】:2012-01-24 19:12:33
【问题描述】:
factory_girl 黄瓜助手很酷。我喜欢这个工作:
Given the following users exist:
| Name | Email |
| Alan | alan@example.com |
| Bob | bob@example.com |
但我不知道如何在步骤定义中调用它们。例如:
Given /the usual users exist/ do
step "the following users exist:
| Name | Email |
| Alan | alan@example.com |
| Bob | bob@example.com |"
end
...抛出Your block takes 1 argument, but the Regexp matched 0 arguments. (Cucumber::ArityMismatchError)。
在步骤定义中使用step 将多行参数传递给另一个步骤的正确方法是什么?
编辑:
源代码总是很方便。我发现step 的签名是def step(name, multiline_argument=nil)。暗示性的。然而很遗憾,
step "the following users exist", "
| Name | Email |
| Alan | alan@example.com |
| Bob | bob@example.com |"
undefined method 'hashes' for #<Cucumber::Ast::DocString:0xa9bf6f4> (NoMethodError) 也会失败。我仍然很想知道它应该如何工作。
不过,也有一线希望。我找到了另一个函数steps,它是def steps(steps_text),它可以工作。查看答案。
【问题讨论】:
标签: ruby-on-rails-3.1 cucumber factory-bot