double v0.6.4 Double
Double builds on-the-fly injectable dependencies for your tests. It does NOT override behavior of existing modules or functions. Double uses Elixir’s built-in language features such as pattern matching and message passing to give you everything you would normally need a complex mocking tool for.
Summary
Functions
Adds a stubbed function to the given map, struct, or module. Structs will fail if they are missing the key given for function_name. Modules will fail if the function is not defined
Clears stubbed functions from a double. By passing no arguments (or nil) all functions will be cleared. A single function name (atom) or a list of function names can also be given
Returns a map that can be used to setup stubbed functions
Same as double/0 but can return structs and modules too
Types
allow_option :: {:with, [...]} | {:returns, any} | {:raises, String.t | {atom, String.t}}
Functions
Adds a stubbed function to the given map, struct, or module. Structs will fail if they are missing the key given for function_name. Modules will fail if the function is not defined.
allow(any, atom, function | [allow_option]) :: struct | map | atom
Clears stubbed functions from a double. By passing no arguments (or nil) all functions will be cleared. A single function name (atom) or a list of function names can also be given.
double(struct, [double_option]) :: struct
double(atom, [double_option]) :: atom
Same as double/0 but can return structs and modules too