Hi Eric,
since your example runs fine, I guess the problem is specific to the mocked object. I try to mock spays RequestContext (see http://spray.cc). So the stripped down failing sample looks as follows
import org.specs2.Specification
import org.specs2.mock.Mockito
import cc.spray.RequestContext
import cc.spray.marshalling.DefaultMarshallers
class MatcherSpec extends Specification { def is =
"This specification should" ^
"be able to use specs2 matchers within verification code" ! c().testIt^
end
case class c() extends Mockito with DefaultMarshallers {
def testIt = {
val ctx = mock[RequestContext]
ctx.complete("this is a test")
there was one(ctx).complete(be_==("this is a test"))(any)
}
}
}
Nevertheless, if you replace the specs2 matcher with a mockito matcher this runs fine.
there was one(ctx).complete(org.mockito.Matchers.eq("this is a test"))(any)
So I guess, since spray brings in an in-scope marshaller this might confuse something. If you are interested you can have a look at the RequestContext's code on github, see
https://github.com/spray/spray/blob/master/spray-server/src/main/scala/cc/spray/RequestContext.scala for details.
For me it now looks like a very specific corner case, I don't know if there are other examples that fail because of a situation like that.
Steffen