黄瓜矛盾的错误信息

问题背景:“使用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 ' ./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:配置是通过带有CS169.x1 @ edX培训轮的Cucumber安装来实现的……

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

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