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

时间:2015-02-12 02:52:42

标签: ruby-on-rails ruby-on-rails-4 cucumber

需要一些帮助来摆脱这个错误。黄瓜不能通过这一步。

 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

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:0)

我修改了下面的代码,它可以根据需要运行。

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