2
factory_girl黃瓜幫手很酷。我喜歡這個作品:黃瓜:在步驟定義中使用「step」方法的多行參數
Given the following users exist:
| Name | Email |
| Alan | [email protected] |
| Bob | [email protected] |
但我不能解決如何在步驟定義中調用它們。例如:
Given /the usual users exist/ do
step "the following users exist:
| Name | Email |
| Alan | [email protected] |
| Bob | [email protected] |"
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 | [email protected] |
| Bob | [email protected] |"
也與undefined method 'hashes' for #<Cucumber::Ast::DocString:0xa9bf6f4> (NoMethodError)
失敗。我仍然很想知道這應該如何工作。
然而,這裏有一線希望。我發現另一個功能steps
,這是def steps(steps_text)
,並且工作。見答案。
不工作 –
@JustinSearls - 完全爲我工作,並已做了過去的一年。 – Chowlett