问题背景:“使用 web_steps.rb 的黄瓜声明性步骤定义”堆栈溢出问题
在对有问题的问题进行故障排除时,会得到两条相互矛盾的错误消息;声明:
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 的训练轮来实现的...