Hi,

I have some caching code that relies on a macro called 'with-redis' so
while writing my tests I'd like to redef this macro to bypass all of
it's redis connection machinery and just execute a function that does
nothing instead.

Something like this works:

(with-redefs [cache/with-redis (fn [& body] (prn "body called"))]
         (cache/with-redis (do "stuff")))
;; "body called"

But this doesn't:
(with-redefs [cache/with-redis (fn [& body] (prn "body called"))]
         (cache/set "key" "value"))

It actually attempts to talk to redis and doesn't run the dummy function at all.

For reference, cache/set is defined as follows, in my cache namespace:

(defn set [key value]
  (with-redis
    (let [key (cache-key key)]
      (redis/set key value))))


It would seem that 'with-redefs' doesn't work if the var your
'redefining' is being used in the body of a function you're calling?

Or hopefully I'm just doing something wrong.


Has anyone seen this before?

Thanks,
Leonardo Borges
www.leonardoborges.com

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to