mockery v1.0.0 Mockery.Assertions

This module contains a set of additional assertion functions.

Link to this section Summary

Functions

Asserts that function from given module with given name or name and arity was called at least once

Asserts that function from given module with given name was called at least once with arguments matching given pattern

Asserts that function from given module with given name or name and arity was NOT called

Asserts that function from given module with given name was NOT called with arguments matching given pattern

Link to this section Functions

Link to this function assert_called(mod, fun)

Asserts that function from given module with given name or name and arity was called at least once.

NOTE: Mockery doesn’t keep track of function calls on modules that weren’t prepared by Mockery.of/2 and for MIX_ENV other than :test

Examples

Assert Mod.fun/2 was called

assert_called Mod, fun: 2

Assert any function named :fun from module Mod was called

assert_called Mod, :fun
Link to this macro assert_called(mod, fun, args) (macro)

Asserts that function from given module with given name was called at least once with arguments matching given pattern.

NOTE: Mockery doesn’t keep track of function calls on modules that weren’t prepared by Mockery.of/2 and for MIX_ENV other than :test

Examples

Assert Mod.fun/2 was called with given args list

assert_called Mod, :fun, ["a", "b"]

You can also use unbound variables inside args pattern

assert_called Mod, :fun, ["a", _second]
Link to this function refute_called(mod, fun)

Asserts that function from given module with given name or name and arity was NOT called.

NOTE: Mockery doesn’t keep track of function calls on modules that weren’t prepared by Mockery.of/2 and for MIX_ENV other than :test

Examples

Assert Mod.fun/2 wasn’t called

refute_called Mod, fun: 2

Assert any function named :fun from module Mod wasn’t called

refute_called Mod, :fun
Link to this macro refute_called(mod, fun, args) (macro)

Asserts that function from given module with given name was NOT called with arguments matching given pattern.

NOTE: Mockery doesn’t keep track of function calls on modules that weren’t prepared by Mockery.of/2 and for MIX_ENV other than :test

Examples

Assert Mod.fun/2 wasn’t called with given args list

refute_called Mod, :fun, ["a", "b"]

You can also use unbound variables inside args pattern

refute_called Mod, :fun, ["a", _second]