I'm testing a function to make sure that it calls a function that's in another namespace. I'd like to stub the function out (using speclj stub), so I can record the invocations.
(defn fn-under-test []
(p/helper-fn))
(describe "test"
(with-stubs)
(around [it]
(with-redefs [p/helper-fn (stub :helper)]
(it)))
(it "should call the helper-fn"
(fn-under-test)
(should-have-invoked :helper {:times 1})))
I get an exception:
java.lang.Exception: Stub recoding not bound. Please add (with-stubs) to the decribe/context.
If helper-fn is defined in the current namespace, everything works as expected. How can I stub a function in another namespace using speclj?
EDIT: The exception occurs when the stubbed function is called from a different thread. I created a pull request that fixes the issue.