Packages
exvcr
0.3.2
0.17.1
0.17.0
0.16.0
0.15.2
0.15.1
0.15.0
0.14.4
0.14.3
0.14.2
0.14.1
0.14.0
0.13.5
0.13.4
0.13.3
0.13.2
0.13.1
0.13.0
0.12.3
0.12.2
0.12.1
0.12.0
0.11.2
0.11.1
0.11.0
0.10.4
0.10.3
0.10.2
0.10.1
0.10.0
0.9.1
0.9.0
0.8.12
0.8.11
0.8.10
0.8.9
0.8.8
0.8.7
0.8.6
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.1
0.6.0
0.5.2
0.5.1
0.5.0
0.4.1
0.4.0
0.3.9
0.3.8
0.3.7
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.1
0.2.0
0.1.7
0.1.6
0.1.5
HTTP request/response recording library for elixir, inspired by VCR.
Current section
Files
Jump to
Current section
Files
lib/exvcr/adapter/ibrowse.ex
defmodule ExVCR.Adapter.IBrowse do
@moduledoc """
Provides adapter methods to mock :ibrowse methods.
"""
use ExVCR.Adapter
defmacro __using__(_opts) do
# do nothing
end
defdelegate convert_from_string(string), to: ExVCR.Adapter.IBrowse.Converter
defdelegate convert_to_string(request, response), to: ExVCR.Adapter.IBrowse.Converter
@doc """
Returns the name of the mock target module.
"""
def module_name do
:ibrowse
end
@doc """
Returns list of the mock target methods with function name and callback.
"""
def target_methods(recorder) do
[ {:send_req, &ExVCR.Recorder.request(recorder, [&1,&2,&3])},
{:send_req, &ExVCR.Recorder.request(recorder, [&1,&2,&3,&4])},
{:send_req, &ExVCR.Recorder.request(recorder, [&1,&2,&3,&4,&5])},
{:send_req, &ExVCR.Recorder.request(recorder, [&1,&2,&3,&4,&5,&6])} ]
end
@doc """
Generate key for searching response.
"""
def generate_keys_for_request(request) do
url = Enum.fetch!(request, 0)
method = Enum.fetch!(request, 2)
[url: url, method: method]
end
@doc """
Callback from ExVCR.Handler when response is retrieved from the HTTP server.
"""
def hook_response_from_server(response) do
filter_sensitive_data(response)
end
defp filter_sensitive_data({:ok, status_code, headers, body}) do
replaced_body = to_string(body) |> ExVCR.Filter.filter_sensitive_data
{:ok, status_code, headers, replaced_body}
end
defp filter_sensitive_data({:error, reason}) do
{:error, reason}
end
@doc """
Default definitions for stub.
"""
def default_stub_params(:headers), do: %{"Content-Type" => "text/html"}
def default_stub_params(:status_code), do: 200
end