mirror of
https://github.com/ash-project/splode.git
synced 2024-09-19 21:02:47 +12:00
fix: Splode.Error.message/1 (#7)
This commit is contained in:
parent
4008406973
commit
61d76e5be3
2 changed files with 13 additions and 1 deletions
|
@ -123,7 +123,7 @@ defmodule Splode.Error do
|
|||
|
||||
Enum.reduce(List.wrap(vars), string, fn {key, value}, acc ->
|
||||
if String.contains?(acc, "%{#{key}}") do
|
||||
String.replace(acc, "%{#{key}}", to_string(value))
|
||||
String.replace(acc, "%{#{key}}", inspect(value))
|
||||
else
|
||||
acc
|
||||
end
|
||||
|
|
12
test/splode/error_test.exs
Normal file
12
test/splode/error_test.exs
Normal file
|
@ -0,0 +1,12 @@
|
|||
defmodule Splode.ErrorTest do
|
||||
use ExUnit.Case
|
||||
|
||||
defmodule InvalidAttribute do
|
||||
use Splode.Error, fields: [:message], class: :invalid
|
||||
end
|
||||
|
||||
test "message" do
|
||||
invalid = %InvalidAttribute{message: "must be in %{list}", vars: [list: [:foo, :bar]]}
|
||||
assert "must be in [:foo, :bar]" == invalid |> Exception.message()
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue