Skip to content

Instantly share code, notes, and snippets.

@tibr
Created Mar 8, 2012
Embed
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],
nil];
// verify initializer
[[process shouldEventually] receive:@selector(initWithIDs:) andReturn:nil withArguments:ids];
});
@tibr
Copy link
Author

tibr commented Mar 8, 2012

Testing Framework is Kiwi: https://github.com/allending/Kiwi
Network request mocking realized with ILCannedURLProtocol.h: https://github.com/InfiniteLoopDK/ILTesting

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