Closed expelledboy closed 8 years ago
Could you please show me your config.exs
file ? Maybe inconsistent versioning strategy was used.
And you can wirte UnitTest like this:
defmodule Skynet.Person.APITest do
use Maru.Test, for: Skynet.Person.API
test "post /person" do
assert %Plug.Conn{} = conn(:post, "/person", %{"name" => "anthony", "phone" => "27745765000"}) |> make_response
end
end
The conn
function comes from Plug.Test.
And for the 2nd question: I'll check and fix it as soon as possible, recommend using the latest release.
I have found the issue. In the post I had to include a body to the post. So my implementation is now:
post do
entry = %Person{name: params[:name], phone: params[:phone]}
|> Repo.insert!
status 200
present entry, with: Skynet.Repo.Entity
end
The error was very misleading.
I can not use the latest version, as I run into the second issue. If you review plug parser you will see that in the init :urlencoded
gets mapped to Plug.Parsers.URLENCODED
. See: https://github.com/elixir-lang/plug/blob/master/lib/plug/parsers.ex
Perfect this works! Thank you
Hi,
I am failing to implement a 'post' macro. Please can you guide me as to what I am doing wrong? And there is very little documentation around testing a post.
Note: I am using Maru version 0.7.1, because anything above results in the following error during tests: