ex_meck v0.2.0 ExMeck

A mocking library particularly suitable for stateful property based testing.

See test/ex_meck_test.ex for example usage.

Link to this section Summary

Functions

As contains?/3 but returns {:error, :no_match} when no match was found or {:ok, match} with the match

Verify wheter the history of the mocked module mod contains a call that satisfies specification spec

Define a mocked function we expect to be called in the test

Create a new mocked module

Reset the history of module mod

Stop all mocked modules

Stop mocking the module

Link to this section Functions

Link to this function contains(mod, spec, timeout \\ 1000)

As contains?/3 but returns {:error, :no_match} when no match was found or {:ok, match} with the match.

This is useful when the match is used for further validation.

Link to this function contains?(mod, spec, timeout \\ 1000)

Verify wheter the history of the mocked module mod contains a call that satisfies specification spec.

The specification is a nested tuple with the form {p, {m,f,a}, r} where p is the pid of the caller m is the module f is function a is a list of arguments r is the result.

The atom :_ can be used as a don’t care value.

Link to this function expect(mod, fun, expectation)

Define a mocked function we expect to be called in the test.

Link to this function new(mod, opts \\ [])

Create a new mocked module.

Reset the history of module mod.

Stop all mocked modules.

Stop mocking the module.