This looks really interesting. Two obligatory questions: 1. Is there any example app that demonstrates how to use Midje? 2. Why would I use Midje instead of clojure.test? (Perhaps you can also blog about it with an example using clojure.test and Midje.)
Regards, Shantanu On Dec 16, 7:01 am, Brian Marick <mar...@exampler.com> wrote: > On Dec 15, 2010, at 6:05 PM, Ken Wesson wrote: > > >> Midje makes it easy to use functions other than equality to check results: > > >> (facts > >> (first (primes-greater-than-2)) => odd? > >> (some-complicated-function) => (in-any-order [1 2 3])) > > > So, a predicate is called on the result instead of tested for equality > > with the result? > > Yes. The use of #'odd? as a checker is just showing off. I'm not sure I've > ever actually used a Clojure function as a checker in real life. I always use > one of Midje's predefined checkers: > > https://github.com/marick/Midje/wiki/Checkers > > > > >> Midje contains other features you might expect from a test framework. For > >> example, when you have to use state, it gives you a way to set it up or > >> tear it down: > > >> (fact > >> (against-background (before :checks (swap! test-atom (constantly > >> 0)))) > >> (swap! test-atom inc) => 1 > >> (swap! test-atom dec) => -1) > > > Why not use (reset! test-atom 0) above? > > For a very subtle reason: I didn't think of it. > > > > >> (background (around :facts (sql/with-connection db ?form))) > > > This doesn't seem to be wrapping anything. What determines its scope? > > #'background's scope is the entire namespace (or, I should say, from the > point it occurs in a file until the end of a file). It's useful for my emacs > midje-mode, where a keypress sends an individual fact to the repl for > checking. (In this case, before the fact is checked, it'll be wrapped with > the connection form.) > > You can also wrap multiple facts with (against-background...) (Putting > against-background inside a fact is another shorthand that makes sending a > single fact to the repl work better.) > > The whole story about "backgrounds" is > here:https://github.com/marick/Midje/wiki/Setup%2C-Teardown%2C-and-Statehttps://github.com/marick/Midje/wiki/Background-prerequisites > > ----- > Brian Marick, Artisanal Labrador > Contract programming in Ruby and Clojure > Author of /Ring/ (forthcoming; > sample:http://bit.ly/hfdf9T)www.exampler.com,www.exampler.com/blog,www.twitter.com/marick -- 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