-
-
Save lvonk/1134230 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.scalatest.matchers.ShouldMatchers | |
import org.scalatra.test.scalatest.ScalatraFunSuite | |
import org.scalatra.ScalatraServlet | |
import org.scalatra.CookieSupport | |
import org.junit.runner.RunWith | |
import org.scalatest.junit.JUnitRunner | |
import org.scalatra.ScalatraFilter | |
import org.scalatra.scalate.ScalateSupport | |
import org.scalatra.FlashMapSupport | |
@RunWith(classOf[JUnitRunner]) | |
class LarsTest extends ScalatraFunSuite with ShouldMatchers { | |
addFilter(new ScalatraFilter with ScalateSupport with FlashMapSupport with CookieSupport { | |
post("/") { | |
cookies.update("foo", "bar") | |
redirect(request.getContextPath) | |
} | |
delete("/") { | |
val token = cookies.get("foo") | |
if (token.isDefined) { | |
response.setHeader("X-Foo-Is-Defined", "true") | |
} | |
status(204) | |
} | |
}, "/*") | |
test("cookie is defined") { | |
session { | |
post("/") { | |
status should equal (302) | |
} | |
delete("/") { | |
status should equal (204) | |
header("X-Foo-Is-Defined") should equal ("true") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment