blob: 836e3ef19b9ed8a37cca4e6d5d61f639e6046cde (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package controllers
import org.scalatestplus.play._
import play.api.test._
import play.api.test.Helpers._
/**
* Add your spec here.
* You can mock out a whole application including requests, plugins etc.
*
* For more information, see https://www.playframework.com/documentation/latest/ScalaTestingWithScalaTest
*/
class HomeControllerSpec extends PlaySpec with OneAppPerTest {
"HomeController GET" should {
"render the index page from a new instance of controller" in {
val controller = new HomeController
val home = controller.index().apply(FakeRequest())
status(home) mustBe OK
contentType(home) mustBe Some("text/html")
contentAsString(home) must include ("Welcome to Play")
}
"render the index page from the application" in {
val controller = app.injector.instanceOf[HomeController]
val home = controller.index().apply(FakeRequest())
status(home) mustBe OK
contentType(home) mustBe Some("text/html")
contentAsString(home) must include ("Welcome to Play")
}
"render the index page from the router" in {
// Need to specify Host header to get through AllowedHostsFilter
val request = FakeRequest(GET, "/").withHeaders("Host" -> "localhost")
val home = route(app, request).get
status(home) mustBe OK
contentType(home) mustBe Some("text/html")
contentAsString(home) must include ("Welcome to Play")
}
}
}
|