Clojure protocols are a great way to encapsulate operations with side
effects, but suffer from a lack of general test tooling. Shrubbery provides
a small set of basic building blocks for working with them:
* stub, which accepts a protocol and a hashmap of functions and returns an
implementation with those functions (functions without implementations
return nil);
* spy, which accepts a protocol and some implementation and returns a new
implementation that tracks the number of times each of its members were
called;
* mock, which wraps a stub in a spy, allowing callers to supply basic
function implementations and assert against those calls; and
* received?, which in conjunction with the Matcher protocol provides a way
to query spies and mocks
Shrubbery was written with clojure.test and Cursive in mind. It should work
nicely with goodies like jump-to-reference and rename-function.
Source here: https://github.com/bguthrie/shrubbery
One major caveat is that it's heavily reliant on macros; my attempts to
reify protocols programmatically didn't work out in the end. However,
Shrubbery's macros introduce no new syntax and carry no side effects.
Feedback welcome!
Cheers,
Brian
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.