Skip to content
Permalink
Browse files
Clarify and fix example of passthrough/1
Example was no longer working on newer Erlang versions because the shell used the string module while being mocked. Adding the passthrough options solved this. Also added an actual example of using the passthrough/1 function in only some clauses. Fixes #224
  • Loading branch information
eproxus committed Feb 17, 2021
1 parent 47b0e96 commit 11021fde6cf10d8c87d26dc948b2edda32b40bfc
Showing 1 changed file with 10 additions and 5 deletions.
@@ -131,16 +131,21 @@ function with the same name as the expect is defined in):

```erlang
Eshell V5.8.4 (abort with ^G)
1> meck:new(string, [unstick]).
1> meck:new(string, [unstick, passthrough]).
ok
2> meck:expect(string, strip, fun(String) -> meck:passthrough([String]) end).
2> meck:expect(string, strip, fun
("foo") -> "bar";
(String) -> meck:passthrough([String])
end).
ok
3> string:strip(" test ").
"test"
4> meck:unload(string).
4> string:strip("foo").
"bar"
5> meck:unload(string).
ok
5> string:strip(" test ").
"test"
5> string:strip("foo").
"foo"
```

## Use

0 comments on commit 11021fd

Please sign in to comment.