rodeo v0.3.0 Rodeo.HTTPCase

Summary

Functions

Starts a cowboy server at a random open TCP port with handler handler (see Rodeo.Handler), calls the passed function and terminates the server instance

Functions

with_webserver(fun)
with_webserver(handler, fun)

Starts a cowboy server at a random open TCP port with handler handler (see Rodeo.Handler), calls the passed function and terminates the server instance.

The function is passed a %Rodeo{} struct.

ExUnit Example

test "my private webserver with explicit require" do
  require Rodeo.HTTPCase
  Rodeo.HTTPCase.with_webserver(:my_handler), fn rodeo ->
    assert is_integer(rodeo.port)
  end
end

test "my private webserver with 'use Rodeo.HTTPCase'" do
  with_webserver(:my_handler, fn rodeo -> assert(is_integer(rodeo.port)) end)
end

test "uses default handler" do
  with_webserver fn rodeo ->
    "Cowboy server running on port #{rodeo.port}"
  end
end