0

在使 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

这些都行不通,但是如果我只这样做

 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

这完美地工作。

为什么我不能在“if”语句中调用另一个步骤?

4

1 回答 1

1

使用 (\d+) 而不是 (.*) 捕获数字。

于 2013-04-23T00:01:09.293 回答