Created
February 18, 2014 13:40
-
-
Save anxiousmodernman/9071173 to your computer and use it in GitHub Desktop.
made use of the FakeApplication() in the Specicification class again
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
class GithubServiceITSpec extends Specification { | |
val app = FakeApplication() | |
val config = Play.configuration(app) | |
implicit val access_token = AccessToken(config.getString("github.oauth.token") getOrElse { | |
throw new IllegalStateException("No github.oauth.token") | |
}) | |
"Github integration" should { | |
"allow fetching all public events for user" in { | |
running(app) { | |
val githubService = new WSGitHubService | |
val events = githubService.fetchPublicEvents("anxiousmodernman")(access_token) | |
val awaited = Await.result(events, Duration("10 seconds")) | |
println(awaited) | |
awaited \ "data" \ "login" should beEqualTo(JsString("anxiousmodernman")) | |
pending | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yup. That's how you grab info from the json.
Also, you might want to consider writing a
JsPath
. This is basically the equivalent of a compiled Regular Expression, but for transforming a tree of JsValues into a different shaped tree. It builds a reusable function that does some piece of extraction. You can compose these like functions, so they are nice when you have a certain shape that you want to extract, but don't want to have to write all the steps in each method.See http://mandubian.com/2012/09/08/unveiling-play-2-dot-1-json-api-part1-jspath-reads-combinators/ for some examples.
I don't think you need it here, but just FYI.