Skip to content

Instantly share code, notes, and snippets.

@klaaspieter
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klaaspieter/9401456 to your computer and use it in GitHub Desktop.
Save klaaspieter/9401456 to your computer and use it in GitHub Desktop.
@interface ViewController : UIViewController
@property (nonatomatic, readwrite, strong) APIClient *apiClient;
@end
@implementation ViewController
- (APIClient *)apiClient;
{
if (!_apiClient) {
_apiClient = [[APIClient alloc] initWithBaseURL:someConfig.baseURL];
}
return _apiClient;
}
@end
#import "SpecHelper.h"
describe(@"ViewController", ^{
__block ViewController *_viewController;
before(^{
_viewController = [[UIStoryboard mainStoryboard] instantiateViewControllerForClass:[ViewController class]];
});
it(@"has a default api client", ^{
expect(_viewController.apiClient).toNot.beNil();
});
it(@"can set a different api client", ^{
APIClient *client = mock([APIClient class]);
_viewController.apiClient = client;
expect(_viewController.apiClient).to.equal(client);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment