I found out, it's quite simple with metadata as of midje 1.6
(fact {:midje/description (str n "not odd")} n => odd?)
質問
I want to write a function to factor out some common facts, like this
(defn check-odd-and-positive
[n]
(fact (str n " not odd") n => odd?)
(fact (str n " not positive") n => positive?))
(facts "about the answer"
(check-odd-and-positive 42))
But it doesn't result in "42 not odd" as the description of the fact. I know a similar effect could be achieved with tabular facts, but I want to be able to share such a fact among fact groups.
解決
I found out, it's quite simple with metadata as of midje 1.6
(fact {:midje/description (str n "not odd")} n => odd?)
他のヒント
You can go with a macro here
(defmacro check-odd-and-positive [n]
`(fact ~(str n " not odd") n => odd?)
`(fact ~(str n " not positive" n => positive?))
However, midje includes the tested value in the report, so I cannot clearly see why this is necessary at all.