Skip to content

Instantly share code, notes, and snippets.

@lukeredpath
Created January 18, 2011 18:56
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 lukeredpath/784929 to your computer and use it in GitHub Desktop.
Save lukeredpath/784929 to your computer and use it in GitHub Desktop.
Keeping tests readable and fluent!
- (void)testCanPerformGetRequestToResourceAndExtractTheResponseAsAString
{
mimicGET(@"/simple/resource", andReturnBody(@"plain text response"), ^{
[client get:resourceWithPath(@"/simple/resource") delegate:self];
});
assertEventuallyThat(&lastResponse, is(responseWithStatusAndBody(200, @"plain text response")));
}
- (void)testCanPostStringToResourceAndHaveThatValueEchoedBack
{
__block LRRestyResponse *receivedResponse = nil;
mimicPOST(@"/echo/test", andEchoRequest(), ^{
[client post:resourceWithPath(@"/echo/test") payload:@"hello world" withBlock:^(LRRestyResponse *response) {
receivedResponse = [response retain];
}];
});
assertEventuallyThat(&receivedResponse, is(responseWithRequestEcho(@"body", @"hello world")));
mimicPOST(@"/echo/test", andEchoRequest(), ^{
[client post:resourceWithPath(@"/echo/test") payload:@"Resty rocks!" withBlock:^(LRRestyResponse *response) {
receivedResponse = [response retain];
}];
});
assertEventuallyThat(&receivedResponse, is(responseWithRequestEcho(@"body", @"Resty rocks!")));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment