此代码:
Then %{I should see the following data in the "Feeds" data grid:
| Name |
| #{name} |}
这一个:
Then "I should see the following data in the \"Feeds\" data grid:
| Name |
| #{name} |"
而且:
Then "I should see the following data in the \"Feeds\" data grid:\n| Name |\n| #{name} |"
即便如此:
Then <<EOS
I should see the following data in the "Feeds" data grid:
| Name |
| #{name} |
EOS
给我:
Your block takes 2 arguments, but the Regexp matched 1 argument.
(Cucumber::ArityMismatchError)
tests/endtoend/step_definitions/instruments_editor_steps.rb:29:in `/^the editor shows "([^"]*)" in the feeds list$/'
melomel-0.6.0/lib/melomel/cucumber/data_grid_steps.rb:59:in `/^I should see the following data in the "([^"]*)" data grid:$/'
tests/endtoend/instruments_editor.feature:11:in `And the editor shows "myFeed" in the feeds list
这一个:
Then "I should see the following data in the \"Feeds\" data grid: | Name || #{name} |"
这一个:
Then "I should see the following data in the \"Feeds\" data grid:| Name || #{name} |"
给出:
Undefined step: "I should see the following data in the "Feeds" data grid:| Name || myFeed |" (Cucumber::Undefined)
./tests/endtoend/step_definitions/instruments_editor_steps.rb:31:in `/^the editor shows "([^"]*)" in the feeds list$/'
tests/endtoend/instruments_editor.feature:11:in `And the editor shows "myFeed" in the feeds list'
答案 0 :(得分:6)
我自己找到了答案:
steps %Q{
Then I should see the following data in the "Feeds" data grid:
| Name |
| #{name} |
}
答案 1 :(得分:3)
上面的说明:可能看起来很明显,但是第一个'{'之后的新行很重要
另一种方式:
Given /^My basic step:$/ do |table|
#do table operation
end
Given /^My referring step:$/ do |table|
table.hashes.each do |row|
row_as_table = %{
|prop1|prop2|
|#{row[:prop1]}|#{row[:prop2]}|
}
Given %{My basic step:}, Cucumber::Ast::Table.parse(row_as_table, "", 0)
end
end
答案 2 :(得分:3)
您也可以使用#table
Then /^some other step$/ do
Then %{I should see the following data in the "Feeds" data grid:}, table(%{
| Name |
| #{name} |
})
end
答案 3 :(得分:0)
考虑使用
Given /^events with:-$/ do |table|
Given %{I am on the event admin page}
table.hashes.each do |row|
Given %{an event with:-}, Cucumber::Ast::Table.new([row]).transpose
end
end
我发现手工制作桌子更加优雅。
事件: - 得到一个像这样的表
| Form | Element | Label |
| foo | bar | baz |
以及带有以下内容的事件: - 获取类似
的表格| Form | foo |
| Element | bar |
| Label | baz |