diff --git a/lib/channel_spec/testing.ex b/lib/channel_spec/testing.ex index d0ff956..b29ac98 100644 --- a/lib/channel_spec/testing.ex +++ b/lib/channel_spec/testing.ex @@ -173,10 +173,12 @@ defmodule ChannelSpec.Testing do topic = unquote(socket).assigns.__channel_topic__ event = unquote(event) + normalized_payload = payload |> Jason.encode!() |> Jason.decode!() + with true <- function_exported?(socket.handler, :__socket_schemas__, 0), %{} = schema <- socket_schema["channels"][topic]["subscriptions"][event] do - case Xema.validate(schema, payload) do + case Xema.validate(schema, normalized_payload) do :ok -> :ok @@ -225,10 +227,12 @@ defmodule ChannelSpec.Testing do topic = unquote(socket).assigns.__channel_topic__ event = unquote(event) + normalized_payload = payload |> Jason.encode!() |> Jason.decode!() + with true <- function_exported?(socket.handler, :__socket_schemas__, 0), %{} = schema <- socket_schema["channels"][topic]["subscriptions"][event] do - case Xema.validate(schema, payload) do + case Xema.validate(schema, normalized_payload) do :ok -> :ok diff --git a/mix.exs b/mix.exs index 9c03051..54d56a8 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule ChannelSpec.MixProject do use Mix.Project @repo_url "https://github.com/felt/channel_spec" - @version "0.1.7" + @version "0.1.8" def project do [