Skip to content
Browse files

fix tests to check content-type for HTML views to be text/html

  • Loading branch information...
1 parent c24f0b7 commit fc5b995aaeb3596a81b4d0d4d629fc6b671589db @jonnyzzz jonnyzzz committed Mar 14, 2013
View
2 src/KaraTests/src/karatests/controllers/ActionTests.kt
@@ -20,6 +20,8 @@ class ActionTests() {
Test fun basicHtmlLayout() {
val response = mockDispatch("GET", "/")
val output = response.stringOutput()
+ assertEquals("text/html", response._contentType, "Content type should be html")
+
assertTrue(output?.contains("Default Layout") as Boolean, "Home view contains layout")
assertTrue(output?.contains("Welcome Home") as Boolean, "Home view contains view")
}
View
5 src/KaraTests/src/karatests/mock/MockHttpServletResponse.kt
@@ -11,6 +11,7 @@ class MockHttpServletResponse() : HttpServletResponse {
val _outSteam = ByteArrayOutputStream()
var _status = HttpServletResponse.SC_OK
+ public var _contentType : String? = null
public fun stringOutput() : String? {
_outSteam.flush()
@@ -90,7 +91,7 @@ class MockHttpServletResponse() : HttpServletResponse {
throw UnsupportedOperationException()
}
public override fun setContentType(p0 : String?) {
- throw UnsupportedOperationException()
+ _contentType = p0
}
public override fun getCharacterEncoding() : String? {
throw UnsupportedOperationException()
@@ -135,4 +136,4 @@ class MockHttpServletResponse() : HttpServletResponse {
throw UnsupportedOperationException()
}
-}
+}

0 comments on commit fc5b995

Please sign in to comment.
Something went wrong with that request. Please try again.