I'm in a regular situation that commonly uses Cucumber as a solution. I'm trying to use Cucumber on a team with unique needs when it comes to translation and shared understanding. 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. I think the community may benefit from @current_table = Cucumber::Ast::Table.new
expects an argument in its initializer.
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
It looks like you might be able to use the parse
method:
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.
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. On another page I read it may also support an array of hashes . But not sure about that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.