Skip to content

Instantly share code, notes, and snippets.

@stevegraham
Created July 20, 2015 03:26
Show Gist options
  • Save stevegraham/0c056c2404e50d451e54 to your computer and use it in GitHub Desktop.
Save stevegraham/0c056c2404e50d451e54 to your computer and use it in GitHub Desktop.
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