Here's a simple specification reproducing the issue:
package ro.igstan.learning
import org.specs2.matcher.ThrownExpectations
import org.specs2.mock.Mockito
import org.specs2.mutable.Specification
import org.specs2.specification.Scope
class LearningSpecs2 extends Specification {
trait Logger {
def error(a: String, b: String)
}
trait mocks extends Mockito with Scope with ThrownExpectations {
val mockedLogger = mock[Logger]
}
"mocking" should {
// passes
"be able to verify arguments passed to mocks" in new mocks {
mockedLogger.error("message", "foo")
got {
one(mockedLogger).error("message", "foo")
}
}
// fails
"be able to *partially* verify arguments passed to mocks" in new mocks {
mockedLogger.error("message", "foo")
got {
one(mockedLogger).error(any, ===("foo"))
}
}
}
}
This is the output:
[info] mocking should
[info] + be able to verify arguments passed to mocks
[error] ! Fragment evaluation error
[error] ThrowableException: org/hamcrest/TypeSafeMatcher (FutureTask.java:303)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2.argThat(LearningSpecs2.scala:27)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2$$anonfun$2.apply$mcV$sp(LearningSpecs2.scala:31)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2$$anonfun$2.apply(LearningSpecs2.scala:31)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2$$anonfun$2.apply(LearningSpecs2.scala:31)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2.got(LearningSpecs2.scala:27)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2.<init>(LearningSpecs2.scala:30)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3.apply(LearningSpecs2.scala:27)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3.apply(LearningSpecs2.scala:27)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2.argThat(LearningSpecs2.scala:27)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2$$anonfun$2.apply$mcV$sp(LearningSpecs2.scala:31)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2$$anonfun$2.apply(LearningSpecs2.scala:31)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2$$anonfun$2.apply(LearningSpecs2.scala:31)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2.got(LearningSpecs2.scala:27)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2.<init>(LearningSpecs2.scala:30)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3.apply(LearningSpecs2.scala:27)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3.apply(LearningSpecs2.scala:27)
[error] org/hamcrest/TypeSafeMatcher
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2.argThat(LearningSpecs2.scala:27)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2$$anonfun$2.apply$mcV$sp(LearningSpecs2.scala:31)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2$$anonfun$2.apply(LearningSpecs2.scala:31)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2$$anonfun$2.apply(LearningSpecs2.scala:31)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2.got(LearningSpecs2.scala:27)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2.<init>(LearningSpecs2.scala:30)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3.apply(LearningSpecs2.scala:27)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3.apply(LearningSpecs2.scala:27)
[error] org.hamcrest.TypeSafeMatcher
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2.argThat(LearningSpecs2.scala:27)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2$$anonfun$2.apply$mcV$sp(LearningSpecs2.scala:31)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2$$anonfun$2.apply(LearningSpecs2.scala:31)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2$$anonfun$2.apply(LearningSpecs2.scala:31)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2.got(LearningSpecs2.scala:27)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3$$anon$2.<init>(LearningSpecs2.scala:30)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3.apply(LearningSpecs2.scala:27)
[error] ro.igstan.learning.LearningSpecs2$$anonfun$3$$anonfun$apply$3.apply(LearningSpecs2.scala:27)
And here are the library versions as reported by the SBT dependency graph plugin:
[info] default:learning_2.9.1:1.0.0
[info] +-junit:junit:4.7
[info] +-org.mockito:mockito-all:1.9.0
[info] +-org.scala-lang:scala-library:2.9.1
[info] +-org.specs2:specs2_2.9.1:1.11
[info] +-org.specs2:specs2-scalaz-core_2.9.1:6.0.1
[info] +-org.scala-lang:scala-library:2.9.1
Any idea what's going on?
Fixed. I had to explicitly specify the Hamcrest version:
libraryDependencies ++= Seq(
"org.specs2" %% "specs2" % "1.11" ,
"org.mockito" % "mockito-all" % "1.9.0",
"org.hamcrest" % "hamcrest-all" % "1.3", // <- this was missing
"junit" % "junit" % "4.7"
)