class FakeApplicationLoader extends ApplicationLoader {
def load(context: Context) = {
new FakeApplicationComponents(context).application // <- contains mocks
}
}
"check that every workse" in new WithDepsApplication{
val home = route(FakeRequest(GET, "/").get
status(home) must equalTo(OK)
contentType(submit) must beSome.which(_ == "text/html")
contentAsString(submit) must contain ("Hello")
}
import play.api.test.WithApplicationLoader
class WithDepsApplication extends WithApplicationLoader(new FakeApplicationLoader)
implicit override lazy val app: FakeApplication = FakeApplication()
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/cbec40d8-5dff-46a3-bb9e-fac61d42772a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/B60DE485-FA32-47B0-A9D1-BBD9C72367BC%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/CAFfBxfH1r2SOuPM8y9%2Bg-F0UHuW_3WDvdg2GNJr5R0L8WD1F%2BA%40mail.gmail.com.
object WithDepsApplication {
def app = {
val appLoader = new FakeApplicationLoader
val context = ApplicationLoader.createContext(
new Environment(new File("."), ApplicationLoader.getClass.getClassLoader, Mode.Test)
)
appLoader.load(context)
}
}
implicit val application = WithDepsApplication.app
*** FAILED ***
class ApplicationTest extends PlaySpec with OneAppPerSuite {
override implicit lazy val app: api.Application = {
val appLoader = new FakeAppLoader
val context = ApplicationLoader.createContext(
new Environment(new File("."), ApplicationLoader.getClass.getClassLoader, Mode.Test)
)
appLoader.load(context)
}
"check that everything works" in {
val play = route(FakeRequest(GET, "/play")).get
status(play) mustEqual OK
contentType(play) mustEqual Some("text/html")
contentAsString(play) must include("Play Framework")
}
}
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/eeae4f51-d86c-4403-97a7-538efc6a8b59%40googlegroups.com.
PS Will blog about it soon…