mockery icon indicating copy to clipboard operation
mockery copied to clipboard

Duplicate binding symbols warning

Open marc-sabates-gelpi opened this issue 4 years ago • 0 comments

Hey Ivan, Thanks for this library, I've been trialing it and I found it very useful.. Thanks

I ran into an unexpected behaviour (at least to me in the beginning) trying to use with-mocks in the following way:

(with-mocks
  [_ {:target ::test-fn}
   _ {:target ::test-fn-2}]
  (test-fn 1)
  (test-fn-2 1 2)
  (is (= @_
         {:called? true
          :call-count 2
          :call-args '(1)
          :call-args-list '[(1) (1 2)]
          :target ::test-fn-2
          :return-list [nil nil]})))

Obviously I was wrongly assuming that I could ignore the mock binding symbol by using _ on both mocks..

Do you think it would be interesting to warn the library users when duplicated binding symbols are used?

I've hacked some code together to print a warning message, though I know it may not be the optimal solution.. I've attached it to this issue..

Tanks again for your work! Marc Sabates mockery-dup-sym-warn.tar.gz

marc-sabates-gelpi avatar Aug 10 '19 09:08 marc-sabates-gelpi