Skip to content

Instantly share code, notes, and snippets.

@jharmn
Last active December 11, 2015 03:18
Show Gist options
  • Select an option

  • Save jharmn/4536191 to your computer and use it in GitHub Desktop.

Select an option

Save jharmn/4536191 to your computer and use it in GitHub Desktop.
Given(~"I access the resource url \"([^\"]*)\"") { String url ->
resp = null
status = null
uri = new URIBuilder(host)
path = url
}
Given(~"I provide parameter \"([^\"]*)\" as \"([^\"]*)\"") { String name, String value ->
uri.addQueryParam name, value
}
When(~"I retrieve the results") { ->
try {
restClient = new RESTClient(uri.toString())
resp = restClient.get(path: path)
} catch (HttpResponseException ex) {
status = ex.getStatusCode()
}
if (resp != null) {
status = resp.status
assert ( resp.data instanceof net.sf.json.JSON )
assert resp.data.status.size() > 0
parsed = resp.data
}
}
Then(~"the status code should be (\\d+)") { int expectedStatusCode ->
assert status == expectedStatusCode
}
Then(~"it should have the field \"(.*)\" containing the value \"(.*)\"") { String field, String value ->
assert parsed."${field}".toString().equals(value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment