specs2 ExceptionMatchers#throwAが予期せぬ挙動をしたのでメモ
なかみ
/** * @return a matcher checking the type of an Exception and its message (as a regexp) */ def throwA[E <: Throwable](message: String = ".*")(implicit m: ClassTag[E]): Matcher[Any] = { throwA(m).like { case e: Throwable => createExpectable(e.getMessage.notNull).applyMatcher(BeMatching.withPart(message)) } }
def suro(): Unit = throw new Exception(")") suro must throwA[Exception](")")
こーしたら
[error] ')' doesn't match '(?s).*).*'
ためしに
"あああああああ" matches ".*あああああああ.*" must beTrue "あああああああ)" matches ".*あああああああ).*" must beTrue
だと
[error] java.util.regex.PatternSyntaxException: Unmatched closing ')' near index 8
[error] .*あああああああ).*
エスケープ必要なだけだったね・・・ とりあえずは、
suro must throwA[Exception](new Exception(")"))