Created
November 12, 2012 11:52
-
-
Save rodrigo-galba/4058942 to your computer and use it in GitHub Desktop.
Rest assured with cucumber step definitions
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
public class TransformationStepdefs { | |
private RequestSpecification spec = RestAssured.with(); | |
@Given("^I have a single \"([^\"]*)\" file$") | |
public void I_have_a_single_file(String format) throws Throwable { | |
spec.given(). | |
multiPart("requestData", objectAsJson()). | |
header("Version", 1); | |
} | |
@Given("^I have a resize action with '(\\d+)x(\\d+)'$") | |
public void I_have_a_resize_action_with_x_(int arg1, int arg2) throws Throwable { | |
spec.given(). | |
multiPart("image", new File("./src/test/resources/file.jpg"), "image/jpeg"). | |
log().all(); | |
} | |
@When("^I render the PDF$") | |
public void I_render_the_PDF() throws Throwable { | |
spec.when(). | |
post("/service"); | |
} | |
@Then("^I should have \"([^\"]*)\" \"([^\"]*)\" image file$") | |
public void I_should_have_image_file(String arg1, String arg2) throws Throwable { | |
spec.expect(). | |
statusCode(200). | |
log().all(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
Thanks for publishing this code. I tried to use this approach testing a REST API, however, the test doesn't fail when a matcher doesn't match. If I use the standard approach:
The same test fails as expected.