/
DevErrorPageSpec.scala
32 lines (27 loc) · 1.15 KB
/
DevErrorPageSpec.scala
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
/*
* Copyright (C) Lightbend Inc. <https://www.lightbend.com>
*/
package play.it.views
import play.api.http.DefaultHttpErrorHandler
import play.api.http.DevHttpErrorHandler
import play.api.test._
class DevErrorPageSpec extends PlaySpecification {
"devError.scala.html" should {
val testExceptionSource = new play.api.PlayException.ExceptionSource("test", "making sure the link shows up") {
def line = 100.asInstanceOf[Integer]
def position = 20.asInstanceOf[Integer]
def input = "test"
def sourceName = "someSourceFile"
}
"link the error line if play.editor is configured" in {
DevHttpErrorHandler.setPlayEditor("someEditorLinkWith %s:%s")
val result = DevHttpErrorHandler.onServerError(FakeRequest(), testExceptionSource)
contentAsString(result) must contain("""href="someEditorLinkWith someSourceFile:100" """)
}
"show prod error page in prod mode" in {
val errorHandler = new DefaultHttpErrorHandler()
val result = errorHandler.onServerError(FakeRequest(), testExceptionSource)
Helpers.contentAsString(result) must contain("Oops, an error occurred")
}
}
}