-
-
Save teamon/97bdfabfcd033270c5d85ea70d591edd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule B do | |
def fun, do: 42 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule C do | |
def fun, do: 42 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule D do | |
def fun, do: 42 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule E do | |
def fun, do: 42 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
⌘ ~/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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