Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make post(path, body) work in tests

Not entirely happy with the solution as it could be tricky to notice the
args have changed order in the future but the is_binary test helps with
that
  • Loading branch information...
commit 31ab8e3753856a2ec455d72451b8a5dd621812bf 1 parent 605643e
Chris McGrath chrismcg authored
Showing with 14 additions and 0 deletions.
  1. +4 −0 lib/dynamo/http/case.ex
  2. +10 −0 test/dynamo/http/case_test.exs
4 lib/dynamo/http/case.ex
View
@@ -197,6 +197,10 @@ defmodule Dynamo.HTTP.Case do
do_process endpoint, Dynamo.Connection.Test.new(method, path)
end
+ def process(endpoint, path, method, body) when is_binary(path) do
+ do_process endpoint, conn(method, path, body)
+ end
+
defp do_process(endpoint, conn) do
conn = endpoint.service(conn)
10 test/dynamo/http/case_test.exs
View
@@ -15,6 +15,11 @@ defmodule Dynamo.HTTP.CaseTest do
get "/get_session" do
conn.send(200, get_session(conn, :hello))
end
+
+ post "/test_post" do
+ conn = conn.fetch :body
+ conn.send 200, conn.req_body
+ end
end
use ExUnit.Case
@@ -37,4 +42,9 @@ defmodule Dynamo.HTTP.CaseTest do
conn = get(conn, "/get_session")
assert conn.sent_body == "world"
end
+
+ test "sees the request body from a post" do
+ conn = post("/test_post", "test body")
+ assert conn.sent_body == "test body"
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.