-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathhttp_case.ex
More file actions
43 lines (32 loc) · 791 Bytes
/
http_case.ex
File metadata and controls
43 lines (32 loc) · 791 Bytes
1
2
3
4
5
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
38
39
40
41
42
43
defmodule HTTPStream.HTTPCase do
use ExUnit.CaseTemplate, async: false
alias HTTPStream.HTTPServer
using do
quote do
import HTTPStream.HTTPHelpers
end
end
setup tags do
config = Application.get_env(:http_stream, HTTPServer)
response_module =
case tags[:respond_with] do
nil -> HTTPServer.RespondWithRequest
module -> module
end
Application.put_env(:http_stream, HTTPServer,
port: config[:port],
respond_with: response_module
)
{:ok, pid} = HTTPServer.start()
on_exit(fn ->
ref = Process.monitor(pid)
HTTPServer.stop()
receive do
{:DOWN, ^ref, _, _, _} ->
:ok
end
Application.put_env(:http_stream, HTTPServer, config)
end)
:ok
end
end