The specs2 Matchers guide states:
throwA[ExceptionType](message = "boom")
additionally checks if the exception message is as expected
But when I use this, the message is apparently matched on the entire stacktrace instead of only the exception message.
Test
"cont'd what if -- running test again shows that the app has already died" in {
running(new FakeApplication(additionalConfiguration = inLocalPostgresDatabase())) {
db2 withSession {
val comboboxOpsClass = new ComboboxOps(database)
}
} must throwA[SQLException](message = "Attempting to obtain a connection from a pool that has already been shutdown")
}
Stacktrace
[error] 'Attempting to obtain a connection from a pool that has already been shutdown.
[error] Stack trace of location where pool was shutdown follows:
[error] java.lang.Thread.getStackTrace(Thread.java:1568)
[error] com.jolbox.bonecp.BoneCP.captureStackTrace(BoneCP.java:572)
[error] com.jolbox.bonecp.BoneCP.shutdown(BoneCP.java:161)
many many more lines
[error] org.specs2.execute.ResultExecution$class.execute(ResultExecution.scala:22)
[error] org.specs2.execute.ResultExecution$.execute(ResultExecution.scala:116)
[error] org.specs2.specification.FragmentExecution$class.executeBody(FragmentExecution.scala:28)
[error]
[error] sbt.ForkMain$Run.runTestSafe(ForkMain.java:211)
[error] sbt.ForkMain$Run.runTests(ForkMain.java:187)
[error] sbt.ForkMain$Run.run(ForkMain.java:251)
[error] sbt.ForkMain.main(ForkMain.java:97)
[error] ' doesn't match '.*Attempting to obtain a connection from a pool that has already been shutdown.*' (FakeApplicationSpec.scala:138)
Could somebody point me to a working example of this usage of specs2?