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

Source

Summary

allow(module, opts \\ [:no_link])

Prepares a module for stubbing. Used in conjunction with .to_receive

to_receive(mocks, mock)

Mocks a function on a module. Used in conjunction with allow

Functions

allow(module, opts \\ [:no_link])

Prepares a module for stubbing. Used in conjunction with .to_receive.

Example

allow MyModule |> to_receive(...)
Source
to_receive(mocks, mock)

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)
Source