Top Level Namespace

Defined Under Namespace

Modules: Demos, Hokusai, LibHokusai

Instance Method Summary collapse

Instance Method Details

#with_app(app, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'ui/spec/spec_helper.rb', line 6

def with_app(app, &block)
  driver = Hokusai::Automation::Driver.new

  backend = Hokusai::Backends::RaylibBackend.new do |config|
    config.automate("localhost", 3000)
    config.automation_driver = driver

    config.width = 500
    config.height = 500
    config.title = "Test application"
  end

  client = nil
  error = nil

  Hokusai::ThreadPool.post do
    client = Hokusai::Automation::Client.start
    
    yield client
  rescue Exception => ex
    error = ex
  ensure
    backend.class.stop!
  end

  init = app.mount
  backend.run(init)

  client&.wait_until_stopped

  raise error if error
end