I have created a helper to do some calculations before a number is presented to the view:
defmodule FourtyWeb.CalculationHelpers do
use Phoenix.HTML
def value_in_euro(amount_in_cents) when is_binary(amount_in_cents) do
cond do
# some code
end
end
end
This thing works. I am now trying to test it:
defmodule FourtyWeb.CalculationHelpersTest do
use FourtyWeb.ConnCase, async: true
import Phoenix.View
@amount_in_cents 1020
describe "it calculates the correct value in euro" do
test "with correct data" do
assert 10.20 == value_in_euro(@amount_in_cents)
end
end
end
If I run mix test I get the following error and I can't figure out why:
== Compilation error in file test/app_web/views/calculation_helpers_test.exs ==
** (CompileError) test/fourty_web/views/calculation_helpers_test.exs:11: undefined function value_in_euro/1
Can anyone elaborate?