Created
July 20, 2015 03:26
-
-
Save stevegraham/0c056c2404e50d451e54 to your computer and use it in GitHub Desktop.
Mockery example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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