05 Jun '12, 1pm

Clojure: expectations & with-redefs

In general, when I'm writing tests, the pure functions end up as bare expects and the impure functions end up as scenarios. The following contrived namespace keeps a list of users and allows you to get the full name of each user. The tests for this namespace would often look something like the following code: It feels natural to put the with-redefs in a scenario, since scenarios also support (and often make use of) stubbing, localize-state, & freeze-time . However, there's really no reason that you need to use a scenario if you're simply looking to redef a var. The following test provides the same level of functionality verification, without needing to use expectations.scenarios: scenarios are great, but these days I try to keep things simple with bare expectations whenever possible.Labels: clojure , expectations Share: Email | Del.icio.us | Digg | Reddit # posted by jaycf...

Full article: http://blog.jayfields.com/2012/06/clojure-expectations-wi...

Tweets

Clojure: Freezing Time in expectations

blog.jayfields.com 29 May '12, 1pm

The current version of expectations (1.4.3) contains support for freezing time within an expectations scenario . I already...

Clojure: expectations, colorized

Clojure: expectations, colorized

blog.jayfields.com 24 May '12, 1pm

The current version of expectations (1.4.3) prints colorized results by default on non-windows boxes. The following screen...

Clojure: name function

blog.jayfields.com 11 Jun '12, 2pm

The 'name' function is a clojure function that returns the string for a keyword, symbol, or string. name - function Usage:...