Class: HtmlTestHook

Inherits:
Mumukit::Hook
  • Object
show all
Defined in:
lib/test_hook.rb

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ HtmlTestHook

Returns a new instance of HtmlTestHook.



5
6
7
8
9
# File 'lib/test_hook.rb', line 5

def initialize(config = nil)
  super config
  @dom_hook = HtmlTestDomHook.new
  @script_hook = HtmlTestScriptHook.new
end

Instance Method Details

#compile(request) ⇒ Object



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

def compile(request)
  request = struct request.to_h.merge options: options(request)
  @script_hook.compile @dom_hook.compile(request)
end

#run!(request) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/test_hook.rb', line 16

def run!(request)
  dom_output, dom_status = @dom_hook.run! request
  script_results = @script_hook.run!(request)
  script_test_results = script_results&.first
  return ["<pre>#{script_test_results}</pre>", :errored] if script_results&.last&.errored?

  if script_test_results.blank?
    [dom_output, dom_status]
  else
    [script_test_results, dom_output, dom_status]
  end
end