【发布时间】:2021-01-18 07:43:40
【问题描述】:
我创建了一个助手来在将数字呈现给视图之前进行一些计算:
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
这东西有效。我现在正在尝试测试它:
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
如果我运行混合测试,我会收到以下错误,但我不知道为什么:
== 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
谁能详细说明?
【问题讨论】: