Reputation: 9724
FakeRequest
comes from artifact play-test
and is added to the project only in the test scope... but I need to create a kind of fake request just to invoke a method that takes an implicit RequestHeader
:
import play.api.test._
...
implicit val request = FakeRequest(
Helpers.POST,
controllers.routes.auth.Users.triggerPasswordReset(superuser.email.get).url,
FakeHeaders(),
""
)
// createToken takes an implict RequestHeader
createToken(TokenType.Reset, account).map { token =>
EmailHelper.sendPasswordResetEmail(user.email.get, token.asJwt)
...
}
How do I import FakeRequest
in the compile scope? Is there a better option? Or shall I invoke the controller's method directly?
Upvotes: 1
Views: 1009
Reputation: 1193
Add the following to your Build.sbt
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-test" % "2.2.1" % "compile"
)
Make sure to change "2.2.1" to be whatever version of Play your are using.
This should expose the play test classes to the compile scope.
Cheers!
Upvotes: 4