Delx v3.0.0 Delx.TestAssertions View Source
A module that contains assertions for ExUnit
to test function delegation.
Note that you need to activate mock mode for your test environment in order to
make the assertions work. In your config/test.exs
file:
config :my_app, Delx, mock: true
Link to this section Summary
Functions
Asserts whether the function specified by MFA (module-function-arity tuple) is
delegated to the the given target module. Accepts the same options as the
Kernel.defdelegate/2
macro.
Refutes whether the function specified by MFA (module-function-arity tuple) is
delegated to the the given target module. Accepts the same options as the
Kernel.defdelegate/2
macro.
Link to this section Functions
assert_delegate(arg, opts \\ []) View Source
Asserts whether the function specified by MFA (module-function-arity tuple) is
delegated to the the given target module. Accepts the same options as the
Kernel.defdelegate/2
macro.
Options
:to
- The module to which the function delegates to.:as
- The name of the function in the target module.
Example
defmodule GreeterTest do
use ExUnit.Case
import Delx.TestAssertions
describe "hello/1" do
test "delegate to Greeter.StringGreeter" do
assert_delegate {Greeter, :hello, 1}, to: Greeter.StringGreeter
end
end
end
refute_delegate(arg, opts \\ []) View Source
Refutes whether the function specified by MFA (module-function-arity tuple) is
delegated to the the given target module. Accepts the same options as the
Kernel.defdelegate/2
macro.
Options
:to
- The module to which the function delegates to.:as
- The name of the function in the target module.
Example
defmodule GreeterTest do
use ExUnit.Case
import Delx.TestAssertions
describe "hello/1" do
test "delegate to Greeter.StringGreeter" do
refute_delegate {Greeter, :hello, 1}, to: Greeter.StringGreeter
end
end
end