aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Blowers <shdblowers@gmail.com>2016-11-22 19:15:38 (GMT)
committerSteven Blowers <shdblowers@gmail.com>2016-11-22 19:15:38 (GMT)
commitb8e4872ab277e8e889d852a2bc6aa19ec7972b9d (patch)
treecb1e73971dcbd100d91e3e3234930e03d019904f
parent7f7ab146f85c4eb4f9645b0d70109fd278e9561d (diff)
downloadzendex-b8e4872ab277e8e889d852a2bc6aa19ec7972b9d.tar.gz
zendex-b8e4872ab277e8e889d852a2bc6aa19ec7972b9d.tar.xz
using pattern matching with context
-rw-r--r--test/zendex/search_test.exs11
1 files changed, 5 insertions, 6 deletions
diff --git a/test/zendex/search_test.exs b/test/zendex/search_test.exs
index 6a292d1..d1e2851 100644
--- a/test/zendex/search_test.exs
+++ b/test/zendex/search_test.exs
@@ -2,7 +2,7 @@ defmodule Zendex.SearchTest do
use ExUnit.Case, async: true
setup do
- [conn: Zendex.Connection.setup("http://test.zendesk.com", "User", "Passw")]
+ %{conn: Zendex.Connection.setup("http://test.zendesk.com", "User", "Passw")}
end
setup_all do
@@ -11,7 +11,7 @@ defmodule Zendex.SearchTest do
:ok
end
- test "doing a search", context do
+ test "doing a search", %{conn: conn} do
stub = fn("http://test.zendesk.com/api/v2/search.json?query=requester%3AJimbob+type%3Aticket", _) ->
%HTTPoison.Response{body: Poison.encode!(["Jimbob Ticket 1", "Jimbob Ticket 2"])}
end
@@ -19,20 +19,19 @@ defmodule Zendex.SearchTest do
expected = ["Jimbob Ticket 1", "Jimbob Ticket 2"]
- actual = Zendex.Search.query(context[:conn],
- %{type: "ticket", requester: "Jimbob"})
+ actual = Zendex.Search.query(conn, %{type: "ticket", requester: "Jimbob"})
assert actual == expected
end
- test "doing a search with sorting", context do
+ test "doing a search with sorting", %{conn: conn} do
stub = fn("http://test.zendesk.com/api/v2/search.json?query=requester%3AReginald+type%3Aticket&sort_by=created_at&sort_order=desc", _) ->
%HTTPoison.Response{body: Poison.encode!(["Reginald Ticket 1", "Reginald Ticket 2"])}
end
:meck.expect(HTTPoison, :get!, stub)
expected = ["Reginald Ticket 1", "Reginald Ticket 2"]
- actual = Zendex.Search.query(context[:conn],
+ actual = Zendex.Search.query(conn,
%{type: "ticket", requester: "Reginald"},
"created_at",
"desc")