Skip to content

Instantly share code, notes, and snippets.

@JoelJWest
Created June 20, 2016 17:34
Show Gist options
  • Save JoelJWest/d9d4ff3bef8081153429776519ce1b92 to your computer and use it in GitHub Desktop.
Save JoelJWest/d9d4ff3bef8081153429776519ce1b92 to your computer and use it in GitHub Desktop.
NSString *textLabel = [NSString new];
id mockHud = OCMClassMock([MBProgressHUD class]);
OCMExpect([mockHud showHUDAddedTo:settingsViewController.view animated:YES]);
OCMExpect([mockHud labelText]).andReturn(textLabel);
OCMExpect([mockHud hide:YES]);
TOCFuture *accountEditFuture = [settingsViewController updateAccount];
XCTAssertNotNil(accountEditFuture, @"Should have received a non-nil instance of %@", [TOCFuture class]);
XCTAssertEqualObjects(textLabel, @"Loading", @"");
__block BOOL callbackInvoked = NO;
[accountEditFuture thenDo:^ (id value) {
XCTAssertNil(value);
callbackInvoked = YES;
}];
[accountEditFuture catchDo:^ (id failure) {
XCTFail(@"Failed unexpectedly: %@", failure);
callbackInvoked = YES;
}];
XCTAssertTrue(callbackInvoked, @"The callback should have been hit no matter what");
OCMVerifyAll(mockController);
OCMVerifyAll(mockEditor);
OCMVerifyAll(mockHud);
[mockEditor stopMocking];
[mockHud stopMocking];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment