Mimic.DSL (Mimic v1.7.4) View Source

Stubs and expectations can be expressed in a more natural way.

use Mimic.DSL
test "basic example" do
  stub Calculator.add(_x, _y), do: :stub
  expect Calculator.add(x, y), do: x + y
  expect Calculator.mult(x, y), do: x * y

  assert Calculator.add(2, 3) == 5
  assert Calculator.mult(2, 3) == 6

  assert Calculator.add(2, 3) == :stub
end

Support for expecting multiple calls:

expect Calculator.add(x, y), num_calls: 2 do
  x + y
end

Link to this section Summary

Link to this section Functions

Link to this macro

expect(ast, opts \\ [], do_block)

View Source (macro)
Link to this macro

stub(arg, opts)

View Source (macro)