There are two problems:
The
prompter
module has two exported functions, but you only mock one of them (gets
) withmeck:expect
. By default, Meck creates a new module that only contains the functions that you explicitly mock. You can change that by using thepassthrough
option:meck:new(prompter, [passthrough]),
When you mock the
gets
function, all module-prefixed calls (i.e.prompter:gets()
) are intercepted, but Meck has no way (yet?) of intercepting internal calls (e.g. thegets()
call in theguess
function), so you would still get the unmocked version of the function. There is no completely satisfactory way to avoid this. You could change the call inguess
toprompter:gets()
, or you could movegets
into a separate module and mock that.