Permalink
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...
1 parent 605643e commit 31ab8e3753856a2ec455d72451b8a5dd621812bf @chrismcg chrismcg committed Dec 8, 2013
Showing with 14 additions and 0 deletions.
  1. +4 −0 lib/dynamo/http/case.ex
  2. +10 −0 test/dynamo/http/case_test.exs
View
4 lib/dynamo/http/case.ex
@@ -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)
View
10 test/dynamo/http/case_test.exs
@@ -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

0 comments on commit 31ab8e3

Please sign in to comment.