Mimic.DSL (Mimic v1.5.1) 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

Support for expecting multiple calls:

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

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)