diff --git a/lib/ex_parameterized/params.ex b/lib/ex_parameterized/params.ex index 0a2a608..12857f7 100644 --- a/lib/ex_parameterized/params.ex +++ b/lib/ex_parameterized/params.ex @@ -89,7 +89,7 @@ defmodule ExUnit.Parameterized.Params do defp escape_values(values) do values - |> Tuple.to_list + |> Tuple.to_list() |> Enum.map(fn x -> case x do value when is_map(value) -> Macro.escape(x) diff --git a/lib/ex_parameterized/params_callback.ex b/lib/ex_parameterized/params_callback.ex index dae33b0..a40461e 100644 --- a/lib/ex_parameterized/params_callback.ex +++ b/lib/ex_parameterized/params_callback.ex @@ -58,7 +58,7 @@ defmodule ExUnit.Parameterized.ParamsCallback do # Quote literals case : http://elixir-lang.org/docs/master/elixir/Kernel.SpecialForms.html#quote/2 defp test_with(desc, context, fun, {{param_desc, values}, num}) when is_atom(param_desc) do - run("'#{desc}': '#{param_desc}': number of #{num}", context, fun, Tuple.to_list(values)) + run("'#{desc}': '#{param_desc}': number of #{num}", context, fun, escape_values(values)) end defp test_with(desc, context, fun, {{_, _, values}, num}), @@ -69,7 +69,7 @@ defmodule ExUnit.Parameterized.ParamsCallback do # Quote literals case : http://elixir-lang.org/docs/master/elixir/Kernel.SpecialForms.html#quote/2 defp test_with(desc, context, fun, {values, num}), - do: run("'#{desc}': number of #{num}", context, fun, Tuple.to_list(values)) + do: run("'#{desc}': number of #{num}", context, fun, escape_values(values)) defp run(desc, context, fun, params) do quote do @@ -88,4 +88,15 @@ defmodule ExUnit.Parameterized.ParamsCallback do defp param_with_index(_) do raise(ArgumentError, message: "Unsupported format") end + + defp escape_values(values) do + values + |> Tuple.to_list() + |> Enum.map(fn x -> + case x do + value when is_map(value) -> Macro.escape(x) + _ -> x + end + end) + end end diff --git a/test/ex_parameterized_callback_test.exs b/test/ex_parameterized_callback_test.exs index cab8e84..e06bfc1 100644 --- a/test/ex_parameterized_callback_test.exs +++ b/test/ex_parameterized_callback_test.exs @@ -166,4 +166,13 @@ defmodule ExParameterizedParamsCallbackTest do {make.(1)} ] end + + test_with_params "with map as second parameter", context, fn a, m -> + assert a == "some" + assert m.a == "world" + end do + [ + {"some", %{a: context[:hello], b: 2, c: 3}} + ] + end end