it(@"should update the tabs after the logout button is tapped",^{// The array of tabs BEFORE the logout button was tappedNSArray*beforeTabs=[tbcviewControllers];// Trigger the method that should swap the tabs around[tbcdidLogoutSuccessfully];// The array of tabs AFTER the logout action was triggeredNSArray*afterTabs=[tbcviewControllers];// The two arrays should be different[[beforeTabsshouldNot]equal:afterTabs];// There SHOULD NOT be a status view controller present in the arrayNSIndexSet*indexesOfStatusVC=[afterTabsindexesOfObjectsPassingTest:^BOOL(idobj,NSUIntegeridx,BOOL*stop){return[objisKindOfClass:[CAStatusViewControllerclass]];}];[[theValue([indexesOfStatusVCcount])should]equal:theValue(0)];// There SHOULD be a login view controller presentNSIndexSet*indexesOfLoginVC=[afterTabsindexesOfObjectsPassingTest:^BOOL(idobj,NSUIntegeridx,BOOL*stop){return[objisKindOfClass:[CALoginViewControllerclass]];}];[[theValue([indexesOfLoginVCcount])should]equal:theValue(1)];// The login view controller should be the first tab[[[[afterTabsobjectAtIndex:0]class]should]beKindOfClass:[CALoginViewControllerclass]];});
And testing that the tabs are locked before and after two methods:
123456789101112131415161718192021222324
it(@"should only allow selection of the first tab before login",^{// iterate across all the view controllers in the viewControllers arrayfor(inti=1;i<[[tbcviewControllers]count];i++){idviewController=[[tbcviewControllers]objectAtIndex:i];// Test that NO gets returned in response to a selection attemptBOOLresponse=[tbctabBarController:tbcshouldSelectViewController:viewController];[[theValue(response)should]equal:theValue(NO)];}});it(@"should allow selection of tabs after login",^{// Trigger the login method, which should unlock the tabs[tbcdidLoginSuccessfully];// iterate across all the view controllers in the viewControllers arrayfor(inti=0;i<[[tbcviewControllers]count];i++){idviewController=[[tbcviewControllers]objectAtIndex:i];// Test that YES gets returned in response to a selection attemptBOOLresponse=[tbctabBarController:tbcshouldSelectViewController:viewController];[[theValue(response)should]equal:theValue(YES)];}});