Skip to content

Commit

Permalink
add test for compile time error, change error type
Browse files Browse the repository at this point in the history
  • Loading branch information
woylie committed Jun 19, 2023
1 parent 7deab8e commit 946a9df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/let_me/builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ defmodule LetMe.Builder do
{module, function, [args]}

{_, _, args} ->
raise """
raise ArgumentError, """
Invalid pre-hook options
Expected pre-hook options to be a keyword list, got:
Expand Down
19 changes: 19 additions & 0 deletions test/let_me/policy_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,25 @@ defmodule LetMe.PolicyTest do
bonus: 1
)
end

test "raises error if pre-hook options are not a list" do
error =
assert_raise ArgumentError, fn ->
defmodule RaiseTestPolicy do
use LetMe.Policy, check_module: MyApp.Checks
alias LetMe.TestHooks

object :some_object do
action :single_mfa_prehook do
pre_hooks {TestHooks, :preload_handsomeness, %{factor: 2}}
allow true
end
end
end
end

assert error.message =~ "Invalid pre-hook options"
end
end

describe "authorize/4" do
Expand Down

0 comments on commit 946a9df

Please sign in to comment.