使用黄瓜步骤定义时的模糊匹配

Ambiguous match while using cucumber step definitions

需要一些帮助来消除这个错误。黄瓜无法通过此步骤。

 And I fill in "Email" with "a1@test.com"               # features/developer_registration.feature:9
      Ambiguous match of "I fill in "Email" with "a1@test.com"":

      features/step_definitions/developer_steps.rb:9:in `/^I fill in "(.*?)" with "(.*?)"$/'
      features/step_definitions/developer_steps.rb:31:in `/^I fill in "(.*?)" with "(.*?)"$/'

steps.rb 中处理此步骤的部分。

When(/^I fill in "(.*?)" with "(.*?)"$/) do |email, password|


  fill_in "a1@test.com", with: email # express the regexp above with the code you wish you had
  fill_in "1", with: password

end

根据输出,您定义了相同的步骤。一次在第 9 行,另一个在第 31 行。您只显示了其中一个定义。

检查这些行中的两个定义,您可能会找到问题的根源。

我修改了下面的代码,它按要求工作了。

When(/^I fill in Email with "(.*?)"$/) do |email|
  fill_in "EMAIL", with: email # express the regexp above with the code you wish you had
end