View Source Double (double v0.8.2)
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.
Link to this section 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.
Returns a specification to start this module under a supervisor.
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
Callback implementation for GenServer.init/1.
Link to this section Types
Specs
Specs
double_option() :: {:verify, true | false}
Link to this section 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.
Specs
Returns a specification to start this module under a supervisor.
See Supervisor.
Specs
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.
Specs
double() :: map()
Returns a map that can be used to setup stubbed functions.
double(source, opts \\ [verify: true, send_stubbed_module: false])
View SourceSpecs
double(struct(), [double_option()]) :: struct()
double(atom(), [double_option()]) :: atom()
Same as double/0 but can return structs and modules too
Callback implementation for GenServer.init/1.