【发布时间】:2015-03-25 10:30:45
【问题描述】:
在 cucumber 中,最好的特性之一是 Table 数据传递。但是,如果我想向其中添加其他数据,或者在我的 step_definitions 中创建一个表数据,我该怎么做呢? Table是什么类型(hash?map?list?array?)?
为了说明,下面是我的步骤之一,从特征接受表格数据,并传递给函数。我喜欢向它附加一些数据。我怎么能这样做?
Then(/^posted JSON should have the below attributes$/) do |table|
## Here I want to append some data to my table. How to do it?
posted_json_attribute_table_check table
end
然后我有一个函数用来与读取的 JSON 进行比较。
def posted_json_attribute_table_check(table)
json = JSON.parse $post_result.lines.first
data = table.raw
data.each do |entry|
status = entry[0]
value = entry[1]
expect(json[status].to_s).to eq(value)
end
end
谢谢!
【问题讨论】: