The following code works (obviously):
(use [midje.sweet])
(with-state-changes [(before :contents (println "setup") :after (println "teardown"))]
(fact "one"
(println "doing 1")
1 => 1)
(fact "two"
(println "doing 2")
(+ 1 1) => 2))
The output is the expected one:
setup
doing 1
doing 2
teardown
But I want to have my facts grouped in a separate function like so:
(defn my-facts []
(fact "one" ...)
(fact "two" ...)
#_( ... ))
(with-state-changes [(before :contents (println "setup") :after (println "teardown"))]
(my-facts))
This time, midje cannot execute the code, I get the following error:
Midje could not understand something you wrote:
Background prerequisites created by the wrapping version of
`against-background` only affect nested facts. This one
wraps no facts.
Note: if you want to supply a background to all checks in a fact,
use the non-wrapping form. That is, instead of this:
(fact
(against-background [(f 1) => 1]
(g 3 2 1) => 8
(h 1 2) => 7))
... use this:
(fact
(g 3 2 1) => 8
(h 1 2) => 7
(against-background (f 1) => 1))
Is there any way to achieve my goal? I want to use midje's setup- and teardown facilities but still be able to have my facts be contained inside a separate fn
.