Class: Mumukit::Bridge::ResponseType::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mumukit/bridge/runner/response_type.rb

Direct Known Subclasses

Structured, Unstructured

Instance Method Summary collapse

Instance Method Details

#global_status(test_status, expectation_status, request) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/mumukit/bridge/runner/response_type.rb', line 14

def global_status(test_status, expectation_status, request)
  if test_status.passed? && expectation_status.failed?
    request[:test].blank? ? :failed : :passed_with_warnings
  else
    test_status
  end
end

#parse(response, request) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/mumukit/bridge/runner/response_type.rb', line 4

def parse(response, request)
  expectation_results = parse_expectation_results(response['expectationResults'] || [])
  feedback = response['feedback'] || ''
  result = response['out'] || ''

  build_hash(response).
      merge(feedback: feedback, expectation_results: expectation_results, result: result).
      update(status: expectation_results.fetch_mumuki_status(:result)) { |_, t, e| global_status(t, e, request) }
end

#parse_expectation_results(results) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/mumukit/bridge/runner/response_type.rb', line 22

def parse_expectation_results(results)
  results.map do |it|
    {binding: it['expectation']['binding'],
     inspection: it['expectation']['inspection'],
     result: it['result'].to_mumuki_status}
  end
end