我在规范中创建了用于启用和停用feature toggles的标签
示例:
@with_toggle_name
Scenario: Example scenario with toggle toggle_name
Given I....
@without_toggle_name
Scenario: Example scenario without toggle toggle_name
Given I....
钩子是这样的:
Around do |scenario, block|
toggles_on = scenario.source_tag_names.map { |t| Regexp.last_match[1].to_sym if t =~ /^@with_(.*)/ }.compact
run_with_toggles(*toggles_on) do
block.call
end
end
Around do |scenario, block|
toggles_off = scenario.source_tag_names.map { |t| Regexp.last_match[1].to_sym if t =~ /^@without_(.*)/ }.compact
run_without_toggles(*toggles_off) do
block.call
end
end
我试图首先执行相同的功能,然后没有功能切换。
这样的事情:
@with_and_without_toggle_name
Scenario: Example scenario with toggle toggle_name
Given I....
用这样的钩子:
Around do |scenario, block|
toggles = scenario.source_tag_names.map { |t| Regexp.last_match[1].to_sym if t =~ /^@with_and_without_(.*)/ }.compact
original_scenario_name = scenario.name
scenario.name = original_scenario.name + " with toggles " + toggles.join(", ")
run_with_toggles(*toggles) do
block.call
end
scenario.name = original_scenario.name + " without toggles " + toggles.join(", ")
run_without_toggles(*toggles) do
block.call
end
end
这样我可以使用不同的名称执行两次相同的功能,但是这段代码不起作用,因为没有更改场景名称的访问者。
有人知道如何做我想做的事吗?