class TextTestHook
Public Instance Methods
compile(request)
click to toggle source
# File lib/test_hook.rb, line 4 def compile(request) { source: request[:content].strip, examples: parse_test(request[:test]) } end
run!(test_definition)
click to toggle source
# File lib/test_hook.rb, line 8 def run!(test_definition) metatest.test(test_definition, test_definition[:examples]) end
Private Instance Methods
metatest()
click to toggle source
# File lib/test_hook.rb, line 14 def metatest Mumukit::Metatest::Framework.new(checker: TextChecker.new, runner: Mumukit::Metatest::IdentityRunner.new) end
parse_multi_scenario_test(parsed_test)
click to toggle source
# File lib/test_hook.rb, line 37 def parse_multi_scenario_test(parsed_test) parsed_test.map { |example| example.deep_symbolize_keys } end
parse_single_scenario_test(parsed_test)
click to toggle source
# File lib/test_hook.rb, line 28 def parse_single_scenario_test(parsed_test) [{ name: 'test', postconditions: { equal: { expected: parsed_test['equal'], ignore_case: parsed_test['ignore_case'].present?, ignore_whitespace: parsed_test['ignore_whitespace'].present? } } }] end
parse_test(tests)
click to toggle source
# File lib/test_hook.rb, line 19 def parse_test(tests) parsed_test = YAML.load(tests) if parsed_test.is_a? Array parse_multi_scenario_test(parsed_test) else parse_single_scenario_test(parsed_test) end end