Skip to content

Instantly share code, notes, and snippets.

@teamon
Created September 14, 2017 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teamon/97bdfabfcd033270c5d85ea70d591edd to your computer and use it in GitHub Desktop.
Save teamon/97bdfabfcd033270c5d85ea70d591edd to your computer and use it in GitHub Desktop.
defmodule A do
use Mockery
@b Mockery.of(B)
@c C
@d Mockery.of("D")
def run do
@b.fun()
@c.fun()
@d.fun()
E.fun()
end
end
defmodule B do
def fun, do: 42
end
defmodule C do
def fun, do: 42
end
defmodule D do
def fun, do: 42
end
defmodule E do
def fun, do: 42
end
⌘ ~/code/sandbox (master) λ mix xref graph
lib/a.ex
├── lib/b.ex (compile)
├── lib/c.ex (compile)
├── lib/mockery.ex (compile)
├── lib/d.ex
└── lib/e.ex
defmodule Mockery do
defmacro __using__(_opts) do
quote do
require Mockery
end
end
defmacro of(module) when is_binary(module) do
mod = Module.concat([module])
quote do: unquote(mod)
end
defmacro of(module) do
quote do: unquote(module)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment