开发者

Passing multiple parameters with Cucumber and Capybara

开发者 https://www.devze.com 2023-03-26 21:42 出处:网络
Hi I need help with Cucumber to Capybara regex match. So I want to have a Cucumber step below: I should see \"10:00, 11:00, 12:00\" under \"div1\"

Hi I need help with Cucumber to Capybara regex match.

So I want to have a Cucumber step below:

I should see "10:00, 11:00, 12:00" under "div1"

I want to pass in "10:00, 11:00. 12:00". In the step I want to do something like:

Then /^I should see "([^\"]*)"+ under "([^\开发者_如何学JAVA"]*)"$/ do | slots, selector_name |
     slots.each do |value|
     end
end

So basically I want to pass in comma separated list of strings and in the step definition I want to treat this list as a array of strings. Is this possible?

Thanks!


What you'd probably want to do is just let the step capture all three times into a single slots item (like you are now), and then do this instead:

slots.split(", ").each do |value|
  ...
end

See this Railscast for an example (it does something similar in its "Given I have articles titled Pizza, Breadsticks" step).

0

精彩评论

暂无评论...
验证码 换一张
取 消