Skip to content

Releases: edgurgel/mimic

Mimic 2.1.1

20 Sep 07:57
Compare
Choose a tag to compare

What's Changed

  • Don't remove behaviour_info/1 from behaviour modules by @escobera in #105

New Contributors

Full Changelog: v2.1.0...v2.1.1

Mimic 2.1.0

31 Aug 08:50
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v2.0.2...v2.1.0

Mimic 2.0.2

11 Aug 22:18
5d97731
Compare
Choose a tag to compare

What's Changed

Full Changelog: v2.0.1...v2.0.2

Mimic 2.0.1

08 Aug 09:01
Compare
Choose a tag to compare
  • Bump ham requirement

Full Changelog: v2.0.0...v2.0.1

Mimic 2.0.0

13 Jul 09:07
fee2662
Compare
Choose a tag to compare

What's Changed

  • feat!: change expect/3,4 to not call original once fulfilled by @edgurgel in #98

Breaking changes

The code below would call the original Calculator.add/2 when all expectations were fulfilled.

 Calculator
 |> expect(:add, fn _, _ -> :expected1 end)
 |> expect(:add, fn _, _ -> :expected2 end)

 assert Calculator.add(1, 1) == :expected1
 assert Calculator.add(1, 1) == :expected2
 assert Calculator.add(1, 1) == 2

Now with Mimic 2 this will raise:

 Calculator
 |> expect(:add, fn _, _ -> :expected1 end)
 |> expect(:add, fn _, _ -> :expected2 end)

 assert Calculator.add(1, 1) == :expected1
 assert Calculator.add(1, 1) == :expected2
 Calculator.add(1, 1)
# Will raise error because more than 2 calls to Calculator.add were made and there is no stub
# ** (Mimic.UnexpectedCallError) Calculator.add/2 called in process #PID<.*> but expectations are already fulfilled

If there is a stub the stub will be called instead. This behaviour is the same as before.

 Calculator
 |> expect(:add, fn _, _ -> :expected1 end)
 |> expect(:add, fn _, _ -> :expected2 end)
 |> stub(:add, fn _, _ -> :stub end)

 assert Calculator.add(1, 1) == :expected1
 assert Calculator.add(1, 1) == :expected2
 assert Calculator.add(1, 1) == :stub

Which means that if someone wants to keep the original behaviour on Mimic 1.* just do the following:

 Calculator
 |> expect(:add, fn _, _ -> :expected1 end)
 |> expect(:add, fn _, _ -> :expected2 end)
 |> stub(:add, fn x, y -> call_original(Calculator, :add, [x, y]) end)

 assert Calculator.add(1, 1) == :expected1
 assert Calculator.add(1, 1) == :expected2
 assert Calculator.add(1, 1) == 2

This way once all expectations are fulfilled the original function is called again.

Full Changelog: v1.12.0...v2.0.0

Mimic 1.12.0

28 May 09:10
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.11.2...v1.12.0

Mimic 1.11.2

02 Apr 07:30
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.11.1...v1.11.2

Mimic 1.11.1

28 Mar 07:21
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.11.0...v1.11.1

Mimic 1.11.0

23 Dec 07:43
Compare
Choose a tag to compare

What's Changed

  • Add elixir 1.18.0 compatibility by @icr4 in #88

New Contributors

  • @icr4 made their first contribution in #88

Full Changelog: v1.10.2...v1.11.0

Mimic 1.10.2

30 Oct 06:56
Compare
Choose a tag to compare

What's Changed

  • enable calling Mimic.allow when not using expectations by @michaelst in #82

New Contributors

Full Changelog: v1.10.1...v1.10.2