|
module ForemanMaintain
|
|
module Concerns
|
|
module ScenarioMetadata
|
|
class DSL < Metadata::DSL
|
|
VALID_STRATEGIES = [:fail_fast, :fail_slow].freeze
|
|
|
|
def initialize(*args)
|
|
super
|
|
# the default strategy is to fail as soon as first step fails
|
|
run_strategy :fail_fast
|
|
end
|
|
|
|
# Possible run strategies:
|
|
#
|
|
# * +:fail_fast+ - the scenario stops as soon as the first step fails
|
|
# * +:fail_slow+ - the step failure doesn't cause the scenario to stop:
|
|
# it runs all the steps, for the tailures to be reported
|
|
# at the end
|
|
def run_strategy(run_strategy)
|
|
unless VALID_STRATEGIES.include?(run_strategy)
|
|
raise "Run strategy #{run_strategy} not one of #{VALID_STRATEGIES}"
|
|
end
|
|
@data[:run_strategy] = run_strategy
|
|
end
|
|
end
|
|
|
|
module ClassMethods
|
|
# modules not to be included in autogenerated labels
|
|
def metadata_class
|
|
ScenarioMetadata::DSL
|
|
end
|
|
end
|
|
|
|
def self.included(klass)
|
|
klass.send(:include, Metadata)
|
|
klass.extend(ClassMethods)
|
|
end
|
|
|
|
def run_strategy
|
|
self.class.metadata[:run_strategy]
|
|
end
|
|
end
|
|
end
|
|
end
|