Skip to content

Instantly share code, notes, and snippets.

@lvonk
Forked from rossabaker/LarsTest.scala
Created August 9, 2011 14:43
Show Gist options
  • Save lvonk/1134230 to your computer and use it in GitHub Desktop.
Save lvonk/1134230 to your computer and use it in GitHub Desktop.
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