Skip to content

Instantly share code, notes, and snippets.

@farmdawgnation
Created May 28, 2013 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farmdawgnation/5666802 to your computer and use it in GitHub Desktop.
Save farmdawgnation/5666802 to your computer and use it in GitHub Desktop.
Some of the specs for the Anchor Tab API.
describe("GET /api/v1/embed/*") {
it("should return 200 and a jscmd for a valid tab id") {
runApiRequest("/api/v1/embed/" + validTab._id.toString, None, _.parameters = List("callback" -> "123")) { response =>
response match {
case Full(JavaScriptResponse(jscmd, _, _, code)) =>
code should equal (200)
case somethingUnexpected => fail(somethingUnexpected.toString)
}
}
}
it("should return a 404 and error for an invalid tab id") {
runApiRequest("/api/v1/embed/BACON", None, _.parameters = List("callback" -> "123")) { response =>
response match {
case Full(InMemoryResponse(data, _, _, code)) =>
code should equal (404)
(new String(data)) should equal ("Unknown tab.")
case somethingUnexpected => fail(somethingUnexpected.toString)
}
}
}
it("should return a 403 and error if the tab has been disabled") {
runApiRequest("/api/v1/embed/" + disabledTab._id.toString, None, _.parameters = List("callback" -> "123")) { response =>
response match {
case Full(InMemoryResponse(data, _, _, code)) =>
code should equal (403)
(new String(data)) should equal ("This tab has been disabled.")
case somethingUnexpected => fail(somethingUnexpected.toString)
}
}
}
it("should return a 400 and error if the callback parameter wasn't specified") {
runApiRequest("/api/v1/embed/" + validTab._id.toString, None) { response =>
response match {
case Full(InMemoryResponse(data, _, _, code)) =>
code should equal (400)
(new String(data)) should equal ("Callback not specified.")
case somethingUnexpected => fail(somethingUnexpected.toString)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment