Skip to content

Instantly share code, notes, and snippets.

@jerodsanto
Created December 14, 2009 04:25
Show Gist options
  • Save jerodsanto/255768 to your computer and use it in GitHub Desktop.
Save jerodsanto/255768 to your computer and use it in GitHub Desktop.
2009-11-13 22:25:12.422 Cappuccino [warn]: undefined
- (BOOL)save
{
var request = [self resourceWillSave];
if (!request)
return NO;
var response = [CPURLConnection sendSynchronousRequest:request];
// console.log(response[0]);
CPLog.warn(response[0]);
if (response[0] >= 400)
return NO;
else
return YES;
}
- (void)testSuccessfulSaveWithNewResource
{
var oldCPURLConnection = CPURLConnection;
var response = [201,'{"user":{"email":"[email protected]","password":"secret"}}'];
CPURLConnection = moq();
[CPURLConnection selector:@selector(sendSynchronousRequest:) arguments:[CPArray array] returns:response];
[self assert:YES equals:[user save]];
[CPURLConnection verifyThatAllExpectationsHaveBeenMet];
CPURLConnection = oldCPURLConnection;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment