Created
February 24, 2010 23:48
-
-
Save revelation/314039 to your computer and use it in GitHub Desktop.
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
- (void)testSetUserAsSuperuser | |
{ | |
// set shared mock: | |
[GHTestCase setSharedMock:[OCMockObject niceMockForClass:[NSUserDefaults class]]]; | |
// set expectations on shared mock: | |
[[[GHTestCase sharedMock] expect] | |
setBool:YES | |
forKey:[OCMArg checkWithSelector:@selector(isEqualToString:) onObject:@"superuser"]]]; | |
// Swizzle in the mock | |
[self swizzle:[NSUserDefaults class] selector:@selector(standardUserDefaults)]; | |
// run implementation | |
[viewController setUserAsSuperuser]; | |
// verify shared mock | |
GHAssertNoThrow([[GHTestCase sharedMock] verify], @"ViewController did not set user as superuser."); | |
// DeSwizzle | |
[self deswizzle]; | |
} | |
#pragma mark - | |
#pragma mark Swizzleable Methods | |
- (NSUserDefaults *)standardUserDefaults | |
{ | |
return [GHTestCase sharedMock]; | |
} |
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
-(void) setUserAsSuperuser | |
{ | |
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"superuser"]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment