Skip to content

Commit f3a4289

Browse files
committed
Basic tests for GCYGroceryStore
1 parent bd54137 commit f3a4289

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

GroceryList.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
D0D60F2C1839FC7A00C09998 /* GCYGroceryItemViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D60F2B1839FC7A00C09998 /* GCYGroceryItemViewModel.m */; };
3131
D0D60F2F1839FEDB00C09998 /* GCYGroceryListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D60F2E1839FEDB00C09998 /* GCYGroceryListViewController.m */; };
3232
D0D60F35183A09E500C09998 /* GCYGroceryItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D60F34183A09E500C09998 /* GCYGroceryItemCell.m */; };
33+
D0E35A6F1867CC1C00B3E6B9 /* GCYGroceryStoreSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E35A6E1867CC1C00B3E6B9 /* GCYGroceryStoreSpec.m */; };
3334
D0EE249E1839AAC800F251AF /* libHockeySDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D0EE24971839AAB300F251AF /* libHockeySDK.a */; };
3435
D0EE24A01839AAD300F251AF /* CrashReporter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0EE249F1839AAD300F251AF /* CrashReporter.framework */; };
3536
D0EE24A21839AADB00F251AF /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0EE24A11839AADB00F251AF /* CoreText.framework */; };
@@ -500,6 +501,7 @@
500501
D0D60F2E1839FEDB00C09998 /* GCYGroceryListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GCYGroceryListViewController.m; sourceTree = "<group>"; };
501502
D0D60F33183A09E500C09998 /* GCYGroceryItemCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCYGroceryItemCell.h; sourceTree = "<group>"; };
502503
D0D60F34183A09E500C09998 /* GCYGroceryItemCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GCYGroceryItemCell.m; sourceTree = "<group>"; };
504+
D0E35A6E1867CC1C00B3E6B9 /* GCYGroceryStoreSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GCYGroceryStoreSpec.m; sourceTree = "<group>"; };
503505
D0EE248E1839AAB300F251AF /* HockeySDK.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = HockeySDK.xcodeproj; path = "External/HockeySDK-iOS/Support/HockeySDK.xcodeproj"; sourceTree = "<group>"; };
504506
D0EE249F1839AAD300F251AF /* CrashReporter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CrashReporter.framework; path = "External/HockeySDK-iOS/Vendor/CrashReporter.framework"; sourceTree = "<group>"; };
505507
D0EE24A11839AADB00F251AF /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/CoreText.framework; sourceTree = DEVELOPER_DIR; };
@@ -970,6 +972,7 @@
970972
isa = PBXGroup;
971973
children = (
972974
D0F4BE0618396F62004A318B /* GCYGroceryItemSpec.m */,
975+
D0E35A6E1867CC1C00B3E6B9 /* GCYGroceryStoreSpec.m */,
973976
);
974977
name = Specs;
975978
sourceTree = "<group>";
@@ -1527,6 +1530,7 @@
15271530
isa = PBXSourcesBuildPhase;
15281531
buildActionMask = 2147483647;
15291532
files = (
1533+
D0E35A6F1867CC1C00B3E6B9 /* GCYGroceryStoreSpec.m in Sources */,
15301534
D0F4BE0718396F62004A318B /* GCYGroceryItemSpec.m in Sources */,
15311535
);
15321536
runOnlyForDeploymentPostprocessing = 0;

GroceryList/GCYGroceryStore.h

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@property (nonatomic, copy, readonly) NSString *name;
1414

1515
// Instantiates a `GCYGroceryStore` based on a tree entry in a repository.
16+
//
17+
// TODO: Put this into a category on OCTTreeEntry instead.
1618
+ (RACSignal *)groceryStoreWithTreeEntry:(OCTTreeEntry *)entry;
1719

1820
// Builds a tree entry with a grocery store and a SHA that points to the desired
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// GCYGroceryStoreSpec.m
3+
// GroceryList
4+
//
5+
// Created by Justin Spahr-Summers on 2013-12-22.
6+
// Copyright (c) 2013 Justin Spahr-Summers. All rights reserved.
7+
//
8+
9+
#import "GCYGroceryStore.h"
10+
11+
SpecBegin(GCYGroceryStore)
12+
13+
NSString *blobSHA = @"deadbeef";
14+
15+
__block OCTTreeEntry *entry;
16+
__block GCYGroceryStore *store;
17+
18+
beforeEach(^{
19+
entry = [OCTTreeEntry modelWithDictionary:@{
20+
@"path": @"Neighborhood Store",
21+
@"type": @(OCTTreeEntryTypeBlob),
22+
@"mode": @(OCTTreeEntryModeFile),
23+
@"SHA": blobSHA
24+
} error:NULL];
25+
26+
store = [GCYGroceryStore modelWithDictionary:@{
27+
@"name": @"Neighborhood Store",
28+
} error:NULL];
29+
30+
expect(entry).notTo.beNil();
31+
expect(store).notTo.beNil();
32+
});
33+
34+
it(@"should instantiate from a tree entry", ^{
35+
GCYGroceryStore *createdStore = [[GCYGroceryStore groceryStoreWithTreeEntry:entry] first];
36+
expect(createdStore).to.equal(store);
37+
});
38+
39+
it(@"should create a tree entry with a given SHA", ^{
40+
OCTTreeEntry *createdEntry = [[store treeEntryWithBlobSHA:blobSHA] first];
41+
expect(createdEntry).to.equal(entry);
42+
});
43+
44+
SpecEnd

0 commit comments

Comments
 (0)