Last active
December 11, 2015 03:18
-
-
Save jharmn/4536191 to your computer and use it in GitHub Desktop.
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
| 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