Module: HTTTee::Server::Mock

Defined in:
lib/htttee/server/mock.rb

Defined Under Namespace

Classes: EchoUri, ThinMuxer

Class Method Summary collapse

Class Method Details

.boot_forking_serverObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/htttee/server/mock.rb', line 7

def self.boot_forking_server
  o,i = IO.pipe

  if pid = fork
    at_exit { Process.kill(:SIGTERM, pid) }

    i.close
    URI.parse(o.read)
  else
    o.close
    process_child(i)
  end
end

.process_child(i) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/htttee/server/mock.rb', line 21

def self.process_child(i)
  EM.run do
    client = Rack::Client.new { run HTTTee::Server.mock_app }

    uri = client.get("/mux-uri").body
    i << uri
    i.close
  end

  exit
end