簡體   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