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.
New in this release: – A throws function, which returns an object suitable for use with the stub function that throws the named exception when invoked, as so: (defprotocol SomeProtocol (explode [t])) (let [astub (shrubbery/stub SomeProtocol {:explode (shrubbery/throws RuntimeException "bang")})] (explode astub)) ;; throws RuntimeException "bang" What Shrubbery provides: * stub, which accepts a variable list of protocols and a optional hashmap of simple value implementations and returns an object that reifies all given protocols; * spy, which accepts an object with at least one protocol 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 * calls/received?, which in conjunction with the Matcher protocol provide a way to query spies and assert against their state. Shrubbery is test-framework-agnostic, avoids altering runtime state to the degree possible, and uses no macros. It supports Clojure versions 1.5-1.8; I haven't yet tested with 1.9. It should work nicely with automated refactoring operations like rename-function. https://github.com/bguthrie/shrubbery [com.gearswithingears/shrubbery "0.4.0"] 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.