私は次の変換を持っています:
Transform /^"([^"]+)" Phase$/ do |name|
# Returns the phase named 'name',
# or raises an exception if it doesn't exist
end
次のようなステップ定義で機能します。
Then /("(?:[^"]+)" Phase) should do something/ do |phase|
# Should fail if the specified phase doesn't exist
end
"([^"]+)" Phase
同じパターンを使用する次のステップ定義もあります。
Given /("([^"]+)" Phase) follows ("([^"]+)" Phase)/ do |pre, post|
# Should create the specified phases
end
ここでは、指定されたフェーズが存在しない場合にステップ定義が失敗しないようにします。代わりにフェーズを作成したいと思います。
ステップ定義を少し DRY するためのフェーズを作成する Transform を作成したいのですが、まったく同じ正規表現を持つ上記の Transform が既にあるため、作成できません。
基本的にはGiven
ステップであればフェーズを作り、そうでなければfailを上げたいと思っています。
何か案は?