2013-01-16 30 views
0

我記得有一種方法可以在另一步中使用菠菜執行一步。從另一步調用一步,菠菜

我記得,這樣的步驟會出現類似以下內容:

... 
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)但還沒有任何運氣得到在步驟對象發送作爲參數。我如何從另一個步驟執行步驟?幫助表示讚賞。

+0

可以找到對象空間所需的步驟,但菠菜確實提供了一個更直接的方式來調用和執行的一個步驟。 – rthbound

回答

1

execute是不應從特徵使用的內部方法。如果你想從另一步執行一個步驟,你必須強調它。菠菜維護者建議將「我是工廠的管理員」和「我創建患者」中的邏輯提取到另一種方法,並從其他步驟調用此方法。

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