# Dummy
Elixir mocking that makes sense. Dummy relies on meck and exposes a simple way
to mock methods, thanks to a couple of assumptions:
- passthrough is enabled
- mocked methods return their arguments
- it's easy to specify replacements
## Installing
```elixir
{:dummy, "~> 1.1.0", only: :test}
```
## Usage
```elixir
use ExUnit.Case
import Dummy
alias MyApp.Module
test "my test" do
dummy OtherModule, ["method"] do
Module.call_to_other_module("arg1")
assert called(OtherModule.method("arg1"))
end
end
```
### Arities
```elixir
test "my test" do
dummy OtherModule, ["method/2"] do
Module.call_to_other_module("arg1", "arg2")
assert called(OtherModule.method("arg1", "arg2"))
end
end
```
### Specifying a return value
```elixir
test "my test" do
dummy OtherModule, [{method, "value"}] do
assert OtherModule.method("anything") == "value"
end
end
```
### Specifying a replacement function
```elixir
test "my test" do
dummy OtherModule, [{method, fn _x -> %{key: => "value"} end}] do
assert OtherModule.method("anything") == %{key: => "value"}
end
end
```
### Multiple replacements
```elixir
test "my test" do
dummy OtherModule, ["method", "other_method"] do
Module.call_to_other_module("arg1")
assert called(OtherModule.method("arg1"))
assert called(OtherModule.other_method("other_arg"))
end
end
```
### Disabling passthrough
```elixir
test "my test" do
dummy OtherModule, ["method"], passthrough: false do
Module.call_to_other_module("arg1")
assert called(OtherModule.method("arg1"))
end
end
```