Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mockery example
defmodule RequestTest do
use ExUnit.Case, async: false
use Mockery
def dsl_test do
Mockery.intercept do
request = %Request{ method: :post, uri: "http://example.com:3000/users", body: "hello=world", headers: %{ "User-Agent" => "My App" } }
response = %Response{ status: 201 }
stub_request request, response
HTTPotion.post "http://example.com:3000/users", [body: "hello=world", headers: ["User-Agent": "My App"]]
assert_request_was_made request
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment