Class: Mumukit::Bridge::Runner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test_runner_url, timeout = 10, headers = {}) ⇒ Runner

Returns a new instance of Runner.



11
12
13
14
15
# File 'lib/mumukit/bridge/runner.rb', line 11

def initialize(test_runner_url, timeout=10, headers={})
  @test_runner_url = test_runner_url
  @timeout = timeout
  @headers = headers
end

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



9
10
11
# File 'lib/mumukit/bridge/runner.rb', line 9

def headers
  @headers
end

#test_runner_urlObject

Returns the value of attribute test_runner_url.



9
10
11
# File 'lib/mumukit/bridge/runner.rb', line 9

def test_runner_url
  @test_runner_url
end

#timeoutObject

Returns the value of attribute timeout.



9
10
11
# File 'lib/mumukit/bridge/runner.rb', line 9

def timeout
  @timeout
end

Instance Method Details

#assets(path, headers = {}) ⇒ Object



56
57
58
# File 'lib/mumukit/bridge/runner.rb', line 56

def assets(path, headers={})
  do_get "assets/#{path}", headers
end

#info(headers = {}) ⇒ Object



60
61
62
# File 'lib/mumukit/bridge/runner.rb', line 60

def info(headers={})
  JSON.parse do_get(:info, json_content_type(headers))
end

#run_query!(request, headers = {}) ⇒ Object

Expects a hash

{query: string, extra: string, content: string}

Returns a hash

{result: string,
 status: :passed|:failed|:errored|:aborted}


37
38
39
40
41
# File 'lib/mumukit/bridge/runner.rb', line 37

def run_query!(request, headers={})
  with_server_response 'query', request, headers do |it|
    {status: it['exit'].to_sym, result: it['out']}
  end
end

#run_tests!(request, headers = {}) ⇒ Object

Expects a hash

{test: string, extra: string, content: string, expectations: [{binding:string, inspection: string})]}

Returns a hash

{result: string,
 test_results: [{title:string, status:symbol, result:string, summary:hash}],
 status: :passed|:failed|:errored|:aborted|:passed_with_warnings,
 expectation_results: [{binding:string, inspection:string, result:symbol}],
 feedback: string}


25
26
27
28
29
30
# File 'lib/mumukit/bridge/runner.rb', line 25

def run_tests!(request, headers={})
  with_server_response 'test', request, headers do |response|
    response_type = ResponseType.for_response response
    response_type.parse response, request
  end
end

#run_try!(request, headers = {}) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/mumukit/bridge/runner.rb', line 43

def run_try!(request, headers={})
  with_server_response 'try', request, headers do |it|
    {
      status: it['exit'].to_sym,
      result: it['out'],
      query_result: it['queryResult'].try do |it|
        { status: it['status'].to_sym,
          result: it['result'] }
      end
    }
  end
end