Some(4) must not(beSomeOneBroken)
}
"not is working for this workaround" in {
None must not(beSomeOneWorking)
Some(4) must not(beSomeOneWorking)
Some(1) must beSomeOneWorking
}
val beSomeOneBroken = ({ opt: Option[Int] => opt }) ^^ beSome.like({ case x => x must_== 1 })
val beSomeOneWorking = ({ opt: Option[Int] => opt }) ^^ beSome and ((_: Option[Int]).get) ^^ beEqualTo(1)
}
The first example is the refactored version of the original, where a custom matcher is built using beSome.like. The second example demonstrates how to build a working matcher that does not use beSome.like. I think the partial function in beSome.like throws a match failure exception that bubbles all the way up (not negated by "not").
Thanks for reading.
Yuesong