crawlie v1.0.0 Crawlie.HttpClient.MockClient
Summary
Functions
Implements the Crawlie.HttpClient
behaviour
A helper :mock_client_fun
returning a :foo
error for any passed url
A helper :mock_client_fun
returning "<html />"
for any passed url
A helper :mock_client_fun
returning a success and the passed url
Functions
Implements the Crawlie.HttpClient
behaviour.
Example
iex> fun = fn(url) -> {:ok, url <> " body"} end
iex> opts = [mock_client_fun: fun]
iex> uri = URI.parse("http://a.bc/")
iex> {:ok, response} = Crawlie.HttpClient.MockClient.get(uri, opts)
iex> response.status_code
200
iex> response.headers
[]
iex> response.body
"http://a.bc/ body"
A helper :mock_client_fun
returning a :foo
error for any passed url.
Example
iex> alias Crawlie.HttpClient.MockClient
iex> fun = MockClient.return_error(:foo)
iex> fun.("http://foo.bar/")
{:error, :foo}