Skip to content

Instantly share code, notes, and snippets.

Created March 8, 2012 15:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Stubbing alloc to return mocked object
it(@"should start the processing with the ids from the network response", ^{
// mock network request
[KWSpec canResponseJSON:@"ids"];
// execute code under test
[client syncMyStuff];
// create mock
id process = [ProcessingOperation mock];
// return mock by stubbing alloc
[[ProcessingOperation shouldEventually] receive:@selector(alloc) andReturn:process];
// setup expected arguments
NSArray *ids = [NSArray arrayWithObjects:
[NSNumber numberWithInteger:2],
[NSNumber numberWithInteger:3],
// verify initializer
[[process shouldEventually] receive:@selector(initWithIDs:) andReturn:nil withArguments:ids];
Copy link

tibr commented Mar 8, 2012

Testing Framework is Kiwi:
Network request mocking realized with ILCannedURLProtocol.h:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment