Giphy v0.1.1 Giphy.API.Mock
A mock version of the Giphy.API
for use in tests. Use it instead of
Giphy.API.HTTP
in your tests:
# config/test.exs
config :giphy, api: Giphy.API.Mock
Then, perform requests against the mock:
Giphy.search("invalid_api_key")
Giphy.search("not_found")
Giphy.search("error")
Giphy.search("valid")
Make Your Own
If this mock does not suit your needs, define your own and use it instead:
defmodule MyApp.Giphy.Mock do
@behaviour Giphy.API
def get("/search", _headers, [{:params, params} | _]) do
# ...
end
end
# In your config/test.exs:
config :giphy, api: MyApp.Giphy.Mock
Summary
Functions
Perform a mock search.
Supports the following search terms:
- “invalid_api_key”: Returns an unauthorized
HTTPoison.Response
. - “not_found”: Returns a 404
HTTPoison.Response
. - “error”: Returns an
HTTPoison.Error
. - “valid”: Returns a single GIF result.