"do sth" in new WithApplication {
val result = route(someCustomRequest(GET, "/some/url")).get
status(result) must equalTo(OK)
contentAsString(result) must contain("""form action="/some/url" method="POST"""")
}
[info] play - Starting application default Akka system.
[info] play - Shutdown application default Akka system.
[info] play - Starting application default Akka system.
[info] play - Shutdown application default Akka system.
[info] play - Starting application default Akka system.
[info] play - Shutdown application default Akka system.
class Actors(implicit app: Application) extends Plugin {
lazy val mailSender = play.api.libs.concurrent.Akka.system.actorOf(Props[MailSender], name = "mailSender")
override def onStart() = {mailSender}
}
object Actors {
def plugin = Play.current.plugin[Actors].getOrElse(throw new RuntimeException("Actors plugin not loaded"))
def mailSender = plugin.mailSender
}
Some people feel that testing against anything else than the real db is a waste of time. However if your controllers are nnontrivial, unit testing against an in-memory db can be worthwhile. I am working on a framework (still experimentalal) that moves your app code from controllers to presenters where they can be tested against a very fast mock db.