Agile Development with Clojure
If you've ever spent any time learning Rails then you probably read one of the editions of Agile Web Development with Rail...
I recently ran into a test that needed (org.joda.time.DateTime .) to always return the same time - so it could easily be asserted against. This situation is fairly common, so it makes sense to add support to expectations . However, I didn't want to force a joda-time dependency on everyone who wanted to use expectations. Luckily, Clojure gives me the ability to conditionally import dependencies. The test looked something like the following code snippet. (scenario (handle-fill (build PartialFill)) (expect {:px 10 :size 33 :time 1335758400000} (in (first @fills)))) note: build is a fn that creates domain objects (I do a lot of Java Interop). The test builds a PartialFill domain object, and passes it to handle-fill. The handle-fill fn converts the domain object to a map and conj's the new map onto the fills vector (which is an atom). The build fn creates a PartialFill who's ti...
Full article: http://blog.jayfields.com/2012/05/clojure-conditionally-i...
@yueliufeeds
»
07 May '12, 11pm
If you've ever spent any time learning Rails then you probably read one of the editions of Agile Web Development with Rail...