class Mumukit::Templates::ExpectationsHook
Constants
- SOURCE_EXPECTATIONS
- SOURCE_EXPECTATION_EVALUATORS
Public Instance Methods
compile(request)
click to toggle source
# File lib/mumukit/templates/expectations_hook.rb, line 11 def compile(request) { request: request, expectations: compile_expectations(request) } end
run!(spec)
click to toggle source
# File lib/mumukit/templates/expectations_hook.rb, line 15 def run!(spec) spec[:expectations][:source].map { |it| it.evaluate spec[:request][:content] } end
Private Instance Methods
compile_expectation(expectation)
click to toggle source
# File lib/mumukit/templates/expectations_hook.rb, line 40 def compile_expectation(expectation) Mulang::Expectation.parse(expectation).as_v2.to_h end
compile_expectations(request)
click to toggle source
# File lib/mumukit/templates/expectations_hook.rb, line 21 def compile_expectations(request) expectations = {ast: [], source: [], exceptions: [], custom: request[:custom_expectations] } request[:expectations].to_a.each do |it| fill_expectations it.deep_symbolize_keys, expectations end expectations end
compile_source_expectation(expectation)
click to toggle source
# File lib/mumukit/templates/expectations_hook.rb, line 44 def compile_source_expectation(expectation) SourceExpectation.parse(expectation) end
fill_expectations(expectation, expectations)
click to toggle source
# File lib/mumukit/templates/expectations_hook.rb, line 29 def fill_expectations(expectation, expectations) inspection = expectation[:inspection] if inspection&.start_with? 'Except:' expectations[:exceptions] << inspection[7..-1] elsif SOURCE_EXPECTATIONS.any? { |it| inspection.starts_with? it } expectations[:source] << compile_source_expectation(expectation) else expectations[:ast] << compile_expectation(expectation) end end