将多个参数传递给黄瓜步骤定义

tok*_*khi 1 ruby-on-rails cucumber

下面的代码将参数传递给黄瓜步骤定义:

Then /^I should see a message "([^\"]*)"$/ do |arg1|
  page.should have_content (arg1)
end
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我,如何传递多个参数?

Pet*_*own 5

In order to pass multiple arguments, you need to have multiple "capture groups". Here's an example that has two capture groups:

Then /^I should see a message "([^\"]*)" and another message "([^\"]*)" $/ do |arg1, arg2|
  page.should have_content(arg1)
  page.should have_content(arg2)
end
Run Code Online (Sandbox Code Playgroud)