1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
module UnitTests
module ValidationMatcherScenarioHelpers
def self.configure_example_group(example_group)
example_group.include(self)
end
def build_scenario_for_validation_matcher(args)
UnitTests::ValidationMatcherScenario.new(
build_validation_matcher_scenario_args(args),
)
end
protected
def validation_matcher_scenario_args
{}
end
def configure_validation_matcher(matcher)
matcher
end
private
def build_validation_matcher_scenario_args(args)
args.
deep_merge(validation_matcher_scenario_args).
deep_merge(
matcher_name:,
matcher_proc: method(matcher_name),
)
end
def matcher_name
validation_matcher_scenario_args.fetch(:matcher_name) do
raise KeyNotFoundError.new(<<-MESSAGE)
Please implement #validation_matcher_scenario_args in your example
group, in such a way that it returns a hash that contains a
:matcher_name key.
MESSAGE
end
end
end
end
|