Created
March 8, 2012 15:43
-
-
Save tibr/2001574 to your computer and use it in GitHub Desktop.
Stubbing alloc to return mocked object
This file contains 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
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]; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Testing Framework is Kiwi: https://github.com/allending/Kiwi
Network request mocking realized with ILCannedURLProtocol.h: https://github.com/InfiniteLoopDK/ILTesting