繁体   English   中英

非正统的黄瓜...在步骤定义中创建黄瓜:: Ast ::表

[英]unorthodox cucumber…creating a Cucumber::Ast::Table in a step definition

语境:

我经常使用Cucumber作为解决方案。 在翻译和共享理解方面,我正在尝试将Cucumber用于具有独特需求的团队。 问题的关键在于,有些人不能使用详细的,字面的,有关正在测试的内容的信息(我称之为混凝土),其他人需要分享对混凝土的理解等。

问题陈述:

我想在步骤定义中制作一个Cucumber::Ast::Table 我认为社区可能会受益于@current_table = Cucumber::Ast::Table.new期望在其初始化器中有一个参数。

我的尝试情况不起作用:

Given(/^an example step that has very well written english but can be misinterpreted and may not be concrete enough for some team members$/) do
  @current_table = Cucumber::Ast::Table.new('''
    | concrete1 | concrete2 |
    | value1    | value2    |
  ''')
end

因为它失败了这个错误:

undefined方法`transpose'代表“\\ n | this | that | \\ n | 1 | 2 | \\ n”:String

看起来你可以使用parse方法:

Given(/^an example step that has very well written english but can be misinterpreted and may not be concrete enough for some team members$/) do
  @current_table = Cucumber::Ast::Table.parse('''
    | concrete1 | concrete2 |
    | value1    | value2    |
  ''', nil, nil)

  p @current_table.class
  #=> Cucumber::Ast::Table

  p @current_table.raw
  #=> [["concrete1", "concrete2"], ["value1", "value2"]]
end

我不确定解析方法的最后两个参数是用于什么的,但是使用nil似乎对于一个简单的情况很好。

http://cukes.info/api/cucumber/ruby/yardoc/Cucumber/Ast/Table.html#initialize-instance_method

声称:: new方法需要一个数组数组。 在另一个页面上,我读到它也可能支持一系列哈希 但不确定。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM