黄瓜矛盾的错误信息

时间:2012-11-26 07:04:18

标签: ruby-on-rails ruby cucumber

Problem Background: "cucumber declarative step definitions using web_steps.rb" Stack Overflow Question

在对问题进行故障排除时,会出现两条相互矛盾的错误消息;声明:

When /^(?:|I )uncheck "([^"]*)"$/ do |field|
  check(field)
end

添加到'features / step_definitions / movie_steps.rb'执行'bundle exec cucumber features / filter_movie_list.feature'导致:

Ambiguous match of "I uncheck "ratings_G"":

features/step_definitions/movie_steps.rb:65:in '/^(?:|I )uncheck "([^"]*)"$/
features/step_definitions/web_steps.rb:65:in '/^(?:|I )uncheck "([^"]*)"$/

但是,删除该步骤不会导致使用'web_steps.rb'中的步骤定义;而是显示不同的错误消息:

When I uncheck the following ratings: G, PG-13                 # features/step_definitions/movie_steps.rb:44
  Undefined step: "When I uncheck "ratings_G"" (Cucumber::Undefined)
  ./features/step_definitions/movie_steps.rb:52:in `block (2 levels) in <top (required)>'
  ./features/step_definitions/movie_steps.rb:49:in `each'
  ./features/step_definitions/movie_steps.rb:49:in `/I (un)?check the following ratings: (.*)/'
  features/filter_movie_list.feature:30:in `When I uncheck the following ratings: G, PG-13'

当两个地方有两个定义时,Cucumber怎么可能会抱怨一个步骤是多余的,但后来却抱怨说当删除副本时没有定义同一个步骤?第二条错误信息是否真的可能意味着除了陈述的内容之外的其他内容?

PS:配置是通过Cucumber安装来实现的,带有CS169.x1 @ edX培训轮...

1 个答案:

答案 0 :(得分:0)

您似乎有一个名为When I uncheck "ratings_G"的定义与错误消息中出现的调用When I uncheck the following ratings: G, P-13有些匹配。黄瓜抱怨没有什么比后者更好。它是否存在于您的代码中?

有些匹配可能会解释您最初获得的歧义警告。该定义匹配但不匹配字符串中的内容。