4

我正在学习使用几年前的指南使用 Aruba 测试 CLI。我收到一个错误

Cucumber::Ambiguous match error

在查看了此类错误的几个示例后,我仍然不确定该怎么做。

  Scenario: Recipes
    When I run `foodie recipe dinner steak`
    Then the following files should exist:
      | dinner/steak.txt |
    Then the file "dinner/steak.txt" should contain:
      """
      ##### Ingredients #####
      Ingredients for delicious steak go here.


      ##### Instructions #####
      Tips on how to make delicious steak go here.
      """

features/step_definitions/extra_aruba_steps.rb我有这个添加的步骤:

Then /^the file "([^"]*)" should contain:$/ do |file, content|
  check_file_content(file, content, true)
end

有人可以解释这个错误以及如何解决它。

提前致谢

彼得阿尔弗林评论后更新:

我包含了 aruba/cucumber,它可以访问所有这些预定义的步骤

完整的错误输出:

Then the file "dinner/steak.txt" should contain: # features/generator.feature:10
      """
      ##### Ingredients #####
      Ingredients for delicious steak go here.


      ##### Instructions #####
      Tips on how to make delicious steak go here.
      """
      Ambiguous match of "the file "dinner/steak.txt" should contain:":

      aruba-0.5.3/lib/aruba/cucumber.rb:300:in `/^the file "([^"]*)" should contain:$/'
      features/step_definitions/aruba_ext_steps.rb:1:in `/^the file "([^"]*)" should contain:$/'

      You can run again with --guess to make Cucumber be more smart about it
       (Cucumber::Ambiguous)
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:147:in `step_match_without_cache'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:138:in `step_match'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:68:in `step_match'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/step_invocation.rb:83:in `find_step_match!'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/step_invocation.rb:56:in `invoke'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/step_invocation.rb:38:in `accept'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:106:in `block in visit_step'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:170:in `broadcast'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:105:in `visit_step'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/step_collection.rb:19:in `block in accept'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/step_collection.rb:18:in `each'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/step_collection.rb:18:in `accept'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:100:in `block in visit_steps'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:170:in `broadcast'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:99:in `visit_steps'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:15:in `block in execute'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:82:in `block (2 levels) in with_hooks'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:98:in `before_and_after'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:81:in `block in with_hooks'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:120:in `call'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:120:in `block (3 levels) in around'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/language_support/language_methods.rb:9:in `block in around'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/language_support/language_methods.rb:97:in `call'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/language_support/language_methods.rb:97:in `execute_around'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/language_support/language_methods.rb:8:in `around'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:119:in `block (2 levels) in around'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:123:in `call'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:123:in `around'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:93:in `around'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:80:in `with_hooks'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:13:in `execute'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/scenario.rb:32:in `block in accept'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/scenario.rb:79:in `with_visitor'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/scenario.rb:31:in `accept'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:58:in `block in visit_feature_element'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:170:in `broadcast'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:57:in `visit_feature_element'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/feature.rb:38:in `block in accept'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/feature.rb:37:in `each'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/feature.rb:37:in `accept'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:27:in `block in visit_feature'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:170:in `broadcast'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:26:in `visit_feature'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/features.rb:28:in `block in accept'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/features.rb:17:in `each'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/features.rb:17:in `each'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/features.rb:27:in `accept'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:21:in `block in visit_features'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:170:in `broadcast'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:20:in `visit_features'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:48:in `run!'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/cli/main.rb:47:in `execute!'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/bin/cucumber:13:in `<top (required)>'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/bin/cucumber:23:in `load'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/bin/cucumber:23:in `<main>'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `eval'
      /Users/Brian/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `<main>'
      features/generator.feature:10:in `Then the file "dinner/steak.txt" should contain:'

Failing Scenarios:
cucumber features/generator.feature:6 # Scenario: Recipes
4

1 回答 1

4

该主题在https://github.com/cucumber/cucumber/wiki/Step-Definitions#ambiguous-steps中直接介绍

如果 Cucumber步骤的文本与两个或多个步骤定义的模式匹配,则 Cucumber 将引发Ambiguous除非--guess指定选项,在这种情况下 Cucumber 将任意选择一个。

顺便说一句,如果您可以在任何 SO 问题中显示完整的错误消息文本,这将很有帮助,特别是当错误消息包含如此多的信息时。

于 2013-07-23T03:50:22.070 回答