[英]Ruby, cucumber, calling a step within a step, within an if statement
In a process of making Gherkin a little more readable, I'm trying to call a step within a step. 在使Gherkin更具可读性的过程中,我尝试在一个步骤中调用一个步骤。
Given /^I am a user with a case with (.*) properties with X enabled$/ do |number|
if number == 2
step "I login as a, 1, 2 user with X num_of_properties_2"
puts "prop2"
elsif number == 1
step "I login as a, 1, 2 user with X num_of_properties_1"
puts "prop1"
end
end
Neither of these will work, however if I do only 这些都不起作用,但是如果我只这样做
Given /^I am a user with a case with (.*) properties with X enabled$/ do |number|
step "I login as a, 1, 2 user with X num_of_properties_2"
end
This works perfectly. 这很完美。
Any reason why I cannot call another step within an "if" statement? 为什么我不能在“ if”语句中调用其他步骤?
用(\\ d +)而不是(。*)捕获数字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.