double v0.5.0 Release Notes

Release Date: 2017-06-21 // almost 7 years ago
  • Behaviour Doubles

    Now a module defining a behaviour can be used as the source of a double. The callbacks will be used in the set of functions verified for proper function name and arity when stubbing.

    defmodule TestBehaviour do
      @callback process(String.t) :: :ok
    end
    
    test "example behaviour stubbing" do
      process_stub = TestBehaviour
      |> double
      |> allow(:process, fn(_arg1) -> :ok end) # This will work fine
      |> allow(:boom, fn -> :ok end) # This will throw a VerifyingDoubleError because it's not defined.
    end
    

    Stubbing against a behaviour may be especially useful when working in a project where the behaviour implementation should be a client concern and you don't have a concrete module to stub against.