I have written the following Midje test:
(fact (followers-minus-friends ...name...) => ["Dude"]
(provided (idset show-followers ...name...) => #{1 2 3}
(idset show-friends ...name...) => #{1 2}
(userinfos #{3}) => [{:screen_name "Dude"}]))
to test the following function (in a different namespace):
(defn followers-minus-friends [screenname]
(let [difference-ids (difference (idset show-followers screenname)
(idset show-friends screenname))
userinfos (userinfos difference-ids)]
(map :screen_name userinfos)))
The test may seem pretty useless, but I'm just trying to get accustomed to Midje. Somehow, the function idset just gets executed, which I wanted to prevent by providing a return value in the provided-clause. What could be an explanation for this?
EDIT: I have uploaded the project to Github here, in case you want to try to reproduce the above situation: https://github.com/Borkdude/twitter-utils
The problem is that the function
idsetis private in your source namespace. In the test file, you intern it in the test namespace. You now have two different vars that point to the same function:In the
provided, you are overriding the second var to point to a prerequisite function. However, the functionfollowers-minus-friendsstill refers to the first var. That is not overridden, so you get the original function.A common idiom for routing around
privatedeclarations is to use the full var name, as above. So you'd expect this to work:It doesn't, though. I consider that a bug in Midje. At least, I can't offhand see what harm supporting that would do. I'll file a ticket.
As it stands, you need to make
idsetpublic.