Skip to content

Instantly share code, notes, and snippets.

@rossabaker
Created August 9, 2011 14:19
Show Gist options
  • Save rossabaker/1134153 to your computer and use it in GitHub Desktop.
Save rossabaker/1134153 to your computer and use it in GitHub Desktop.
import org.scalatra._
import org.scalatra.test.scalatest._
import org.scalatest.matchers._
class LarsTest extends ScalatraFunSuite with ShouldMatchers {
addServlet(new ScalatraServlet 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