Skip to content

Instantly share code, notes, and snippets.

@sam
Created September 5, 2013 15:43
Show Gist options
  • Save sam/6451952 to your computer and use it in GitHub Desktop.
Save sam/6451952 to your computer and use it in GitHub Desktop.
Simple example of a Play Framework / ScalaTest spec using functional composition to keep the building of two similar Requests (only difference is the Request-Method) DRY.
"Delete" taggedAs(tag.RolesTag) in {
val request = (FakeRequest(_:String, "/admin/roles/role-bob")) andThen
withAdminCredentials andThen
(route(_:FakeRequest[AnyContentAsEmpty.type]))
for { result <- request(DELETE) } {
status(result) must equal(SEE_OTHER)
flash(result).data must contain key("deleted")
}
for { result <- request(GET) } {
status(result) must equal(NOT_FOUND)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment