Pavlov.Mocks
Use this module to mock methods on a given module.
Example
defmodule MySpec do
use Pavlov.Mocks
describe "My Tests" do
...
end
end
Summary↑
allow(module, opts \\ [:no_link]) | Prepares a module for stubbing. Used in conjunction with
|
to_receive(mocks, mock) | Mocks a function on a module. Used in conjunction with
|
Functions
Prepares a module for stubbing. Used in conjunction with
.to_receive
.
Example
allow MyModule |> to_receive(...)
Mocks a function on a module. Used in conjunction with
allow
.
Example
allow MyModule |> to_receive(get: fn(url) -> "<html></html>" end)
For a method that takes no arguments and returns nil, you may use a simpler syntax:
allow MyModule |> to_receive(:simple_method)