(apologies if this double-posts; I seem to be having trouble with Google Groups today)
I would like to test a fact that my function handles intermittent throw exceptions like this:
(fact "`my-fn` handles exceptions thrown by `might-throw`"
(my-fn "foo") => "bar"
(provided
(might-throw "foo") =streams=> [(Exception.) "bar" ]))
But =streams=> doesn't seem to handle throwables. I could use
(fact "`my-fn` handles exceptions thrown by `might-throw`"
(my-fn "foo") => "bar"
(provided
(might-throw "foo") =throws=> (Exception.)))
for the throwable, but when I add a second prerequisite like this
(fact "`my-fn` handles exceptions thrown by `might-throw`"
(my-fn "foo") => "bar"
(provided
(might-throw "foo") =throws=> (Exception.)
(might-throw "foo") => "bar"))
the second (non-throwing) version doesn't seem to get used (as I expected).
When something is hard in Midje, I assume I'm on the wrong path. What's a better way to test this behavior?
Barry