Skip to content

Instantly share code, notes, and snippets.

@saiday
Last active September 17, 2015 15:28
Show Gist options
  • Select an option

  • Save saiday/fe60b1518d33144f6bad to your computer and use it in GitHub Desktop.

Select an option

Save saiday/fe60b1518d33144f6bad to your computer and use it in GitHub Desktop.
@interface ViewControllerTests : XCTestCase
@property (nonatomic) CustomViewController *viewController;
@property (nonatomic) BOOL beenDealloc;
@property (nonatomic) id<AspectToken> aspectToken;
@end
- (void)setUp {
[super setUp];
self.viewController = [[CustomViewController alloc] init];
@weakify(self);
self.aspectToken = [self.viewController aspect_hookSelector:NSSelectorFromString(@"dealloc") withOptions:AspectPositionBefore usingBlock:^(id<AspectInfo> aspectInfo) {
@strongify(self);
self.beenDealloc = YES;
}error:nil];
}
- (void)tearDown {
self.viewController = nil;
assertThatBool(self.beenDealloc, isTrue());
[self.aspectToken remove];
[super tearDown];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment