Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for spying on namespaced protocols without :refer :all #5

Closed
rkaercher opened this issue Jul 28, 2015 · 1 comment
Closed

Comments

@rkaercher
Copy link

Disclaimer: I might very well be doing it wrong.

When trying to spy on a protocol I usually only require the protocol and not :all from the namespace to avoid pollution of the tests namespace. However, with the current implementation of the spy macro I cannot do this. To clarify, this is how the problem is reproducible:

user> (ns test1)
nil
test1> (defprotocol TestProto (a [this arg]))
TestProto
test1> (ns test2)
nil
test2> (require '[shrubbery.core :as s])
nil
test2> (require 'test1)
nil
test2> (def fake-impl (reify test1/TestProto (a [_ _] :fake)))
#'test2/fake-impl
test2> (s/spy test1/TestProto fake-impl)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(/tmp/form-init8310557090395405498.clj:1:1)

If I require everything from the test1 namespace it works:

test2> (require '[test1 :refer :all])
nil
test2> (s/spy TestProto fake-impl)
#object[test2$eval35584$reify__35585 0x48c2232f "test2$eval35584$reify__35585@48c2232f"]

Is there a way to make it work? I.e. by taking the namespace into account or prefixing the methods with a dot when generating the proxy calls in the macro?

@bguthrie
Copy link
Owner

bguthrie commented Oct 1, 2015

You were not doing it wrong! This was a genuine issue. Fixing it took a fair amount of internal rework but there are now tests to cover this use and it should be resolved in v0.3.0. Sorry it took so long to resolve.

@bguthrie bguthrie closed this as completed Oct 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants