Class: HtmlTestScriptHook

Inherits:
Mumukit::Templates::FileHook
  • Object
show all
Defined in:
lib/test_script_hook.rb

Instance Method Summary collapse

Instance Method Details

#command_line(filename) ⇒ Object



16
17
18
# File 'lib/test_script_hook.rb', line 16

def command_line(filename)
  "run-dom-tests #{filename}"
end

#compile(request) ⇒ Object



4
5
6
7
8
# File 'lib/test_script_hook.rb', line 4

def compile(request)
  return request if script_test(request).blank?

  struct request.to_h.merge file: super(request)
end

#compile_file_content(request) ⇒ Object



20
21
22
23
# File 'lib/test_script_hook.rb', line 20

def compile_file_content(request)
  JSON.generate html: request.content,
                tests: script_test(request)
end

#post_process_file(_file, result, status) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/test_script_hook.rb', line 25

def post_process_file(_file, result, status)
  report = JSON.parse(result)
  test_results = generate_test_results report

  [test_results, :passed]
rescue
  [result, :errored]
end

#run!(request) ⇒ Object



10
11
12
13
14
# File 'lib/test_script_hook.rb', line 10

def run!(request)
  return nil if script_test(request).blank?

  super request.file
end