我想模拟带有函数参数和函数参数的方法,并结合咖喱参数,例如:
trait Secured {
def IsAuthenticated(f: AuthenticatedData => Request[AnyContent] => Result) = {
// auth code
f(AuthenticatedData.create(request))(request)
}
def IsOwnerOfTestrun(id: String)(f: Testrun => AuthenticatedData =>
Request[AnyContent] => Result) =
IsAuthenticated { authenticatedData => implicit request => {
// auth code
f(testrun)(authenticatedData)(request)
}
}
我如何在 Secured 特征中模拟这些方法?
我将 Play 2.1.1 / Scala 2.10.0 与 ScalaMock 3.0.1 与 Specs2 一起使用:
"org.scalamock" %% "scalamock-specs2-support" % "3.0.1" % "test"