amitrathore / conjure

a mocking library for clojure
http://s-expressions.com
73 stars 9 forks source link

How to mock functions implemented by protocols? #8

Open mikavilpas opened 9 years ago

mikavilpas commented 9 years ago

Hi, I started using your library for a toy project, and it works great. I first used it with regular functions, but then decided to refactor my functions into a protocol, which several implementations can exist for.

Now I have an implementation of my protocol, but don't know a good way to mock its functions. The best I could come up with is for the protocol to call a regular worker function which I then can mock normally.

This is the error I get. As far as I can tell it has nothing to do with conjure per se.

CompilerException java.lang.RuntimeException: Unable to resolve
    symbol: get-shell-command-output-worker in this context,
    compiling:(/home/mika/git/random-wallpaper/app/src/app/os_implementations/linux_mint.clj:28:5)

In my case get-shell-command-output is a function that does I/O, that I'd like to mock in unit tests.