【问题标题】:Call one step from within another, Spinach从另一个中调用一个步骤,菠菜
【发布时间】:2013-01-16 21:47:47
【问题描述】:

我记得有一种方法可以使用菠菜从另一个步骤中执行一个步骤。

我记得,这样的步骤类似于以下内容:

...
step "I create a patient as a facility's administrator" do
  %Q{ Given I am a facility's administrator }
  %Q{ Given I create a patient }
end
...

找到.execute(step),但没有任何运气可以将 Step 对象作为参数发送。如何从另一个步骤中执行步骤?感谢您的帮助。

【问题讨论】:

  • 可以在 ObjectSpace 中找到所需的步骤,但肯定菠菜提供了一种更直接的方式来调用和执行步骤。

标签: ruby-on-rails gherkin spinach


【解决方案1】:

execute 是一种内部方法,不应在功能中使用。如果你想从另一个步骤执行一个步骤你必须下划线。 Spinach 维护人员建议将“我是设施管理员”和“我创建患者”步骤中的逻辑提取到另一个方法中,并从其他步骤中调用这个方法。

step "I create a patient as a facility's administrator" do
  log_as_facility_admin
  create_patient
end

def log_as_facility_admin
  # something
end

def create_patient
  # something
end

来源:https://github.com/codegram/spinach/issues/132

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-26
    • 1970-01-01
    • 2015-01-10
    • 2022-11-22
    相关资源
    最近更新 更多