Skip to content

Commit

Permalink
Replace Poison with Jason, closes #444 (#446)
Browse files Browse the repository at this point in the history
* Replace Poison with Jason
  • Loading branch information
michallepicki committed Jul 26, 2019
1 parent 2eca111 commit 4657693
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
3 changes: 1 addition & 2 deletions dialyzer.ignore_warnings
@@ -1,4 +1,3 @@
:0: Unknown function 'Elixir.Mix':shell/0
:0: Unknown function 'Elixir.Mix.Tasks.Coveralls':do_run/2
lib/mix/tasks/safe_travis.ex:1: Callback info about the 'Elixir.Mix.Task' behaviour is not available
lib/wallaby/experimental/chrome/logger.ex:35: The pattern
lib/mix/tasks/safe_travis.ex:1: Callback info about the 'Elixir.Mix.Task' behaviour is not available
4 changes: 2 additions & 2 deletions lib/wallaby/experimental/chrome/logger.ex
Expand Up @@ -30,8 +30,8 @@ defmodule Wallaby.Experimental.Chrome.Logger do

defp format_string(message) do
unescaped = String.replace(message, ~r/\\(.)/, "\\1")
case Poison.decode(unescaped) do
{:ok, data} -> "\n#{Poison.encode!(data, pretty: true)}"
case Jason.decode(unescaped) do
{:ok, data} -> "\n#{Jason.encode!(data, pretty: true)}"
{:error, _} -> unescaped
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/wallaby/httpclient.ex
Expand Up @@ -26,7 +26,7 @@ defmodule Wallaby.HTTPClient do
make_request(method, url, params)
end
def request(method, url, params, _opts) do
make_request(method, url, Poison.encode!(params))
make_request(method, url, Jason.encode!(params))
end

defp make_request(method, url, body), do: make_request(method, url, body, 0, [])
Expand Down Expand Up @@ -59,7 +59,7 @@ defmodule Wallaby.HTTPClient do
{:ok, %{"value" => nil}}

{:ok, %HTTPoison.Response{body: body}} ->
with {:ok, decoded} <- Poison.decode(body),
with {:ok, decoded} <- Jason.decode(body),
{:ok, response} <- check_status(decoded),
{:ok, validated} <- check_for_response_errors(response),
do: {:ok, validated}
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Expand Up @@ -40,7 +40,7 @@ defmodule Wallaby.Mixfile do
end

def application do
[applications: [:logger, :httpoison, :poolboy, :poison], mod: {Wallaby, []}]
[extra_applications: [:logger], mod: {Wallaby, []}]
end

defp elixirc_paths(:test), do: ["lib", "test/support"]
Expand All @@ -50,8 +50,8 @@ defmodule Wallaby.Mixfile do

defp deps do
[
{:jason, "~> 1.1"},
{:httpoison, "~> 0.12 or ~> 1.0"},
{:poison, ">= 1.4.0"},
{:poolboy, "~> 1.5"},
{:dialyxir, "~> 0.5", only: [:dev], runtime: false},
{:earmark, "~> 1.2", only: :dev},
Expand Down
1 change: 1 addition & 0 deletions mix.lock
Expand Up @@ -17,6 +17,7 @@
"httpoison": {:hex, :httpoison, "1.1.1", "96ed7ab79f78a31081bb523eefec205fd2900a02cda6dbc2300e7a1226219566", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "5.1.1", "cbc3b2fa1645113267cc59c760bafa64b2ea0334635ef06dbac8801e42f7279c", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
"inch_ex": {:hex, :inch_ex, "0.5.6", "418357418a553baa6d04eccd1b44171936817db61f4c0840112b420b8e378e67", [:mix], [{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"jsx": {:hex, :jsx, "2.8.2", "7acc7d785b5abe8a6e9adbde926a24e481f29956dd8b4df49e3e4e7bcc92a018", [:mix, :rebar3], [], "hexpm"},
"makeup": {:hex, :makeup, "0.8.0", "9cf32aea71c7fe0a4b2e9246c2c4978f9070257e5c9ce6d4a28ec450a839b55f", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
Expand Down
2 changes: 1 addition & 1 deletion test/support/http_client_case.ex
Expand Up @@ -29,7 +29,7 @@ defmodule Wallaby.HttpClientCase do
Parses the body of an incoming http request
"""
def parse_body(conn) do
opts = Plug.Parsers.init(parsers: [:urlencoded, :json], json_decoder: Poison)
opts = Plug.Parsers.init(parsers: [:urlencoded, :json], json_decoder: Jason)
Plug.Parsers.call(conn, opts)
end
end
2 changes: 1 addition & 1 deletion test/wallaby/experimental/chrome/logger_test.exs
Expand Up @@ -49,7 +49,7 @@ defmodule Wallaby.Experimental.Chrome.LoggerTest do
|> Logger.parse_log
end

assert capture_io(fun) == "\n{\n \"href\": \"http://localhost:54579/logs.html\",\n \"ancestorOrigins\": {}\n}\n"
assert capture_io(fun) == "\n{\n \"ancestorOrigins\": {},\n \"href\": \"http://localhost:54579/logs.html\"\n}\n"
end

test "can be disabled" do
Expand Down
4 changes: 2 additions & 2 deletions test/wallaby/experimental/selenium/webdriver_client_test.exs
Expand Up @@ -718,7 +718,7 @@ defmodule Wallaby.Experimental.Selenium.WebdriverClientTest do
handle_request bypass, fn conn ->
assert conn.method == "POST"
assert conn.request_path == "/session/#{session.id}/keys"
assert conn.body_params == Wallaby.Helpers.KeyCodes.json(keys) |> Poison.decode!
assert conn.body_params == Wallaby.Helpers.KeyCodes.json(keys) |> Jason.decode!

resp(conn, 200, ~s<{
"sessionId": "#{session.id}",
Expand All @@ -738,7 +738,7 @@ defmodule Wallaby.Experimental.Selenium.WebdriverClientTest do
handle_request bypass, fn conn ->
assert conn.method == "POST"
assert conn.request_path == "/session/#{session.id}/element/#{element.id}/value"
assert conn.body_params == Wallaby.Helpers.KeyCodes.json(keys) |> Poison.decode!
assert conn.body_params == Wallaby.Helpers.KeyCodes.json(keys) |> Jason.decode!

resp(conn, 200, ~s<{
"sessionId": "#{session.id}",
Expand Down
4 changes: 2 additions & 2 deletions test/wallaby/phantom/driver_test.exs
Expand Up @@ -593,7 +593,7 @@ defmodule Wallaby.Phantom.DriverTest do

stub_backend bypass, session, fn conn ->
if conn.method == "POST" && conn.request_path == "/session/#{session.id}/keys" do
assert conn.body_params == Wallaby.Helpers.KeyCodes.json(keys) |> Poison.decode!
assert conn.body_params == Wallaby.Helpers.KeyCodes.json(keys) |> Jason.decode!

resp(conn, 200, ~s<{
"sessionId": "#{session.id}",
Expand All @@ -614,7 +614,7 @@ defmodule Wallaby.Phantom.DriverTest do
stub_backend bypass, session, fn conn ->
if conn.method == "POST" &&
conn.request_path == "/session/#{session.id}/element/#{element.id}/value" do
assert conn.body_params == Wallaby.Helpers.KeyCodes.json(keys) |> Poison.decode!
assert conn.body_params == Wallaby.Helpers.KeyCodes.json(keys) |> Jason.decode!

resp(conn, 200, ~s<{
"sessionId": "#{session.id}",
Expand Down

0 comments on commit 4657693

Please sign in to comment.