【问题标题】:Cucumber: Tables were not identical (Cucumber::Ast::Table::Different)Cucumber:表格不相同(Cucumber::Ast::Table::Different)
【发布时间】:2013-01-15 08:10:04
【问题描述】:

我正在使用 cucumber 来测试场景。我收到以下错误:

表格不相同(Cucumber::Ast::Table::Different)

在我的代码中使用 diff! 时。

Then /^the results should be:$/ do |expected_results|
results = [['content']] + page.all('ol.results li').map do |li|
[li.text]
end 
expected_results.diff!(results)
end

我也参考了大多数与这些问题相关的网站,因为在diff! 之前使用transpose 方法我没有成功。另外,我关注了https://github.com/cucumber/cucumber/issues/220,但对这个错误没有影响。谁能定义我如何解决这个错误?

【问题讨论】:

    标签: mysql ruby-on-rails rspec cucumber capybara


    【解决方案1】:

    我不确定您是否已经这样做了,但看起来您正在使用进度格式化程序,它没有提供有关表差异错误的任何有用的详细信息。

    如果您使用带有--format pretty 标志的漂亮格式化程序,黄瓜应该打印出表差异的完整详细信息。

    【讨论】:

    • 不确定这是否被 OP 否决了? @devilsmind 您能否添加 --format pretty 的输出,以便我们可以看到表之间的实际差异?或者添加 expected_results.to_s 的结果
    【解决方案2】:

    这可能是由乱序的行引起的(根据The Cucumber docs,乱序的列得到了很好的处理,但乱序的行显然不是)。

    在我的例子中,我通过在我的 SQL 语句中使用显式 ORDER BY 并重新排序预期表中的行来完成这项工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-19
      相关资源
      最近更新 更多