lundi 26 août 2019

Elixir Testing: Ensure a module defines a callback

I'm trying write a test that verifies that a behaviour defines the callbacks it's supposed to. How should I do this?

I have a module that defines a callback, for example:

defmodule MyModule do
    @callback my_callback(arg :: binary) :: any
end

I want to ensure that my_callback/1 is defined by MyModule.

Since @callback is an attribute, I tried calling MyModule.__info__(:attributes), but the callback was not present in the response.

Aucun commentaire:

Enregistrer un commentaire