[英]unorthodox cucumber…creating a Cucumber::Ast::Table in a step definition
I'm in a regular situation that commonly uses Cucumber as a solution. 我经常使用Cucumber作为解决方案。 I'm trying to use Cucumber on a team with unique needs when it comes to translation and shared understanding.
在翻译和共享理解方面,我正在尝试将Cucumber用于具有独特需求的团队。 The gist of the problem is that some people cannot use detailed, literal, information on what is being tested (I will call that the concretes), other people need to share an understanding of the concretes, etc.
问题的关键在于,有些人不能使用详细的,字面的,有关正在测试的内容的信息(我称之为混凝土),其他人需要分享对混凝土的理解等。
I have a want to make a Cucumber::Ast::Table
inside a step definition. 我想在步骤定义中制作一个
Cucumber::Ast::Table
。 I think the community may benefit from @current_table = Cucumber::Ast::Table.new
expects an argument in its initializer. 我认为社区可能会受益于
@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 method `transpose' for "\\n|this|that|\\n|1|2|\\n":String undefined方法`transpose'代表“\\ n | this | that | \\ n | 1 | 2 | \\ n”:String
It looks like you might be able to use the parse
method: 看起来你可以使用
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
I am not sure what the last 2 parameters of the parse method are used for, but using nil seems to work fine for a simple case. 我不确定解析方法的最后两个参数是用于什么的,但是使用nil似乎对于一个简单的情况很好。
http://cukes.info/api/cucumber/ruby/yardoc/Cucumber/Ast/Table.html#initialize-instance_method http://cukes.info/api/cucumber/ruby/yardoc/Cucumber/Ast/Table.html#initialize-instance_method
The ::new method is claimed to expect an array of arrays. 声称:: new方法需要一个数组数组。 On another page I read it may also support an array of hashes .
在另一个页面上,我读到它也可能支持一系列哈希 。 But not sure about that.
但不确定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.