From 7215f7e1fc49d7e785a0d440ce657f67dd2ac3fc Mon Sep 17 00:00:00 2001 From: Ash Furrow Date: Thu, 26 Dec 2013 09:21:51 -0500 Subject: [PATCH] Unit testing! --- FRP/FRPGalleryViewModel.m | 8 ++++++-- FRPTests/FRPGalleryViewModelTests.m | 22 ++++++++++++---------- Podfile | 4 ++-- Podfile.lock | 12 ++++++------ 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/FRP/FRPGalleryViewModel.m b/FRP/FRPGalleryViewModel.m index 9c3e0f1..111ecbb 100644 --- a/FRP/FRPGalleryViewModel.m +++ b/FRP/FRPGalleryViewModel.m @@ -1,4 +1,4 @@ -// + // // FRPGalleryViewModel.m // FRP // @@ -21,9 +21,13 @@ self = [super init]; if (!self) return nil; - RAC(self, model) = [[[FRPPhotoImporter importPhotos] logError] catchTo:[RACSignal empty]]; + RAC(self, model) = [self importPhotosSignal]; return self; } +-(RACSignal *)importPhotosSignal { + return [[[FRPPhotoImporter importPhotos] logError] catchTo:[RACSignal empty]]; +} + @end diff --git a/FRPTests/FRPGalleryViewModelTests.m b/FRPTests/FRPGalleryViewModelTests.m index c7ec5f3..ad9e13e 100644 --- a/FRPTests/FRPGalleryViewModelTests.m +++ b/FRPTests/FRPGalleryViewModelTests.m @@ -12,20 +12,22 @@ #import "FRPGalleryViewModel.h" #import "FRPPhotoImporter.h" +@interface FRPGalleryViewModel () + +-(RACSignal *)importPhotosSignal; + +@end + SpecBegin(FRPGalleryViewModel) describe(@"FRPGalleryViewModel", ^{ - beforeAll(^{ - // This is run once and only once before all of the examples - // in this group and before any beforeEach blocks. - }); - - beforeEach(^{ - // This is run before each example. - }); - it(@"should be initialized and call importPhotos", ^{ - STAssertTrue(false, @"Test not implemented."); + id mockObject = [OCMockObject mockForClass:[FRPGalleryViewModel class]]; + [[[mockObject expect] andReturn:[RACSignal empty]] importPhotosSignal]; + + mockObject = [mockObject init]; + + [mockObject verify]; }); }); diff --git a/Podfile b/Podfile index 2b8a9a0..a8c6495 100644 --- a/Podfile +++ b/Podfile @@ -16,8 +16,8 @@ pod 'ReactiveCocoa', '2.1.4' pod 'ReactiveViewModel', '0.1.1' pod 'libextobjc', '0.3' pod '500px-iOS-api', '1.0.5' -pod 'Specta', '~> 0.1.11' +pod 'Specta', '~> 0.2.1' pod 'Expecta', '~> 0.2' pod 'OCMock', '~> 2.0.1' -end \ No newline at end of file +end diff --git a/Podfile.lock b/Podfile.lock index fd46448..34ea027 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -94,8 +94,8 @@ PODS: - ReactiveCocoa/no-arc - ReactiveCocoa/no-arc (2.1.4) - ReactiveViewModel (0.1.1): - - ReactiveCocoa (= 2.1.4) - - Specta (0.1.11) + - ReactiveCocoa (~> 2.1) + - Specta (0.2.1) - SVProgressHUD (0.9) DEPENDENCIES: @@ -105,7 +105,7 @@ DEPENDENCIES: - OCMock (~> 2.0.1) - ReactiveCocoa (= 2.1.4) - ReactiveViewModel (= 0.1.1) - - Specta (~> 0.1.11) + - Specta (~> 0.2.1) - SVProgressHUD (= 0.9) SPEC CHECKSUMS: @@ -115,8 +115,8 @@ SPEC CHECKSUMS: libffi: 64ef39353e747bb2b25e1026afd96a157bf9231c OCMock: f0c099603f851d07f8d7f2efe26d05da721ec43f ReactiveCocoa: 0e8725dd3c609128144c15192f4dbdab827f54ae - ReactiveViewModel: 43714642e73dc029f4a23ca28cad6f4c57eb8487 - Specta: 82746c6fd70b104c5d37cfbadb7bf15a2cbc4da0 + ReactiveViewModel: e6cba4e138cfdaac19ea326bf42f6d6a61245f2c + Specta: 2d06220591110c6d9757d8be8ecf8e63aa40dc2a SVProgressHUD: 03d4845ec8e64591726428a08236c6a5489d45f8 -COCOAPODS: 0.26.2 +COCOAPODS: 0.28.0