A better solution that looks like it works is this: load the mock module
second. Say I have a module I want to mock:
(ns tomock)
(defn foo [] 4)
and a module that requires it:
(ns totest
(:require tomock))
(defn bar [] (tomock/foo))
So if I create the file mock_tomock.clj which contains:
What I'd like to do is mock a full name-space for the purpose of testing
other functions that use or require the original name-space. Do people have
ideas or best practices for how I can do this?
The problem comes in that I very much prefer doing my uses/requires in the
name space declaration.
Brian,
I don't blame you -- I wouldn't want to put conditional requires in my
code either. Did you consider putting your mock code in a different
classpath?
Here is another idea. It's tempting to suggest that you write your
own version of ns that mucks with its arguments and then passes the