Moxinet.Mock (moxinet v0.3.0)
Supports building a custom mock.
Usage
While it out of the box will support interactivity
with Moxinet.expect/4
, you'll also be able to treat it like
a Plug and define your own match
definitions to enable static
fallbacks. See Plug.Router
docs for more details.
defmodule GithubMock do
use Moxinet.Mock
get "/pull-requests/closed" do
send_resp(conn, 200, [%{id: "1", closed: true}])
end
end
Since the mock is just another plug, you can choose to use/build custom plugs to extend its functionality as a way to add extra verification that your API module does what you want it to do, or to replicate a complex API interaction.
defmodule GithubMock do
use Moxinet.Mock
import Plug.BasicAuth
plug :basic_auth, username: "user", password: "s3cr3t_p4s5w0rd"
end