Skip to content

Commit

Permalink
Test for decorate_all with custom attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
ludwikbukowski committed Oct 1, 2018
1 parent 22b6c5c commit e0eeff9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/decorate_all_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 26,28 @@ defmodule DecoratorDecorateAllTest.Fixture.MyModule do

def empty_body(10), do: 11
def empty_body(n), do: n 2

end

defmodule DecoratorDecorateAllTest.Fixture.MyModuleWithAttribute do
use DecoratorDecorateAllTest.Fixture.MyDecorator

@decorate_all some_decorator()

@custom_attr 15
@custom_attr_map %{some_val: 3, other_val: 10}

def fun1(x), do: x 2

def fun2(x), do: x @custom_attr

def fun3(x), do: x @custom_attr_map[:some_val]
end

defmodule DecoratorDecorateAllTest do
use ExUnit.Case
alias DecoratorDecorateAllTest.Fixture.MyModule
alias DecoratorDecorateAllTest.Fixture.MyModuleWithAttribute

test "decorate_all" do
assert {:ok, 4} == MyModule.square(2)
Expand All @@ -40,5 57,8 @@ defmodule DecoratorDecorateAllTest do
assert {:ok, 666} == MyModule.value666()
assert {:ok, 11} == MyModule.empty_body(10)
assert {:ok, 8} == MyModule.empty_body(6)
assert {:ok, 10} == MyModuleWithAttribute.fun1(8)
assert {:ok, 20} == MyModuleWithAttribute.fun2(5)
assert {:ok, 8} == MyModuleWithAttribute.fun3(5)
end
end

0 comments on commit e0eeff9

Please sign in to comment.