Created
May 10, 2013 17:57
-
-
Save doitian/5556169 to your computer and use it in GitHub Desktop.
Play Framework 2.1.1 Controller Test
This file contains hidden or 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
| package controllers | |
| import org.specs2.mutable._ | |
| import play.api.libs.json.Json | |
| import play.api.test._ | |
| import play.api.test.Helpers._ | |
| class EventsSpec extends Specification { | |
| val jsonHeaders = Seq( | |
| CONTENT_TYPE -> Seq("application/json"), | |
| ACCEPT -> Seq("application/json") | |
| ) | |
| val json = Json.toJson(Map("host" -> "127.0.0.1")) | |
| "create" should { | |
| "insert json to database" in new WithApplication { | |
| val req = FakeRequest("POST", "/events", FakeHeaders(jsonHeaders), json) | |
| val result = Events.create()(req) | |
| status(result) must equalTo(CREATED) | |
| contentType(result) must beSome("application/json") | |
| contentAsString(result) must contain("$oid") | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment