一个非常晚的响应,但对于后代,我刚刚发现另一种方法是采用基于状态的方法,并将您的视图控制器实际粘贴到一个真正的导航控制器中。然后,您可以戳您的视图控制器并通过检查导航控制器的状态来测试它对导航堆栈的作用。这是一个例子:
it(@"displays the station chooser when you tap the 'Choose station' button", ^{
// Given
LaunchViewController *launchViewController = [LaunchViewController newWithNearestStationLocator:nil];
[launchViewController view];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:launchViewController];
// When
[[launchViewController chooseStationBtn] sendActionsForControlEvents:UIControlEventTouchUpInside];
// Then
[[theValue(navController.viewControllers.count) should] equal:theValue(2)];
[[NSStringFromClass(navController.visibleViewController.class) should] equal:@"StationsViewController"];
});