mirror of
https://github.com/zhigang1992/GroceryList.git
synced 2026-04-29 12:35:03 +08:00
@@ -30,6 +30,7 @@
|
||||
D0D60F2C1839FC7A00C09998 /* GCYGroceryItemViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D60F2B1839FC7A00C09998 /* GCYGroceryItemViewModel.m */; };
|
||||
D0D60F2F1839FEDB00C09998 /* GCYGroceryListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D60F2E1839FEDB00C09998 /* GCYGroceryListViewController.m */; };
|
||||
D0D60F35183A09E500C09998 /* GCYGroceryItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D60F34183A09E500C09998 /* GCYGroceryItemCell.m */; };
|
||||
D0E35A6F1867CC1C00B3E6B9 /* GCYGroceryStoreSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E35A6E1867CC1C00B3E6B9 /* GCYGroceryStoreSpec.m */; };
|
||||
D0EE249E1839AAC800F251AF /* libHockeySDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D0EE24971839AAB300F251AF /* libHockeySDK.a */; };
|
||||
D0EE24A01839AAD300F251AF /* CrashReporter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0EE249F1839AAD300F251AF /* CrashReporter.framework */; };
|
||||
D0EE24A21839AADB00F251AF /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0EE24A11839AADB00F251AF /* CoreText.framework */; };
|
||||
@@ -500,6 +501,7 @@
|
||||
D0D60F2E1839FEDB00C09998 /* GCYGroceryListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GCYGroceryListViewController.m; sourceTree = "<group>"; };
|
||||
D0D60F33183A09E500C09998 /* GCYGroceryItemCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCYGroceryItemCell.h; sourceTree = "<group>"; };
|
||||
D0D60F34183A09E500C09998 /* GCYGroceryItemCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GCYGroceryItemCell.m; sourceTree = "<group>"; };
|
||||
D0E35A6E1867CC1C00B3E6B9 /* GCYGroceryStoreSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GCYGroceryStoreSpec.m; sourceTree = "<group>"; };
|
||||
D0EE248E1839AAB300F251AF /* HockeySDK.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = HockeySDK.xcodeproj; path = "External/HockeySDK-iOS/Support/HockeySDK.xcodeproj"; sourceTree = "<group>"; };
|
||||
D0EE249F1839AAD300F251AF /* CrashReporter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CrashReporter.framework; path = "External/HockeySDK-iOS/Vendor/CrashReporter.framework"; sourceTree = "<group>"; };
|
||||
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 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D0F4BE0618396F62004A318B /* GCYGroceryItemSpec.m */,
|
||||
D0E35A6E1867CC1C00B3E6B9 /* GCYGroceryStoreSpec.m */,
|
||||
);
|
||||
name = Specs;
|
||||
sourceTree = "<group>";
|
||||
@@ -1527,6 +1530,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D0E35A6F1867CC1C00B3E6B9 /* GCYGroceryStoreSpec.m in Sources */,
|
||||
D0F4BE0718396F62004A318B /* GCYGroceryItemSpec.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
@property (nonatomic, copy, readonly) NSString *name;
|
||||
|
||||
// Instantiates a `GCYGroceryStore` based on a tree entry in a repository.
|
||||
//
|
||||
// TODO: Put this into a category on OCTTreeEntry instead.
|
||||
+ (RACSignal *)groceryStoreWithTreeEntry:(OCTTreeEntry *)entry;
|
||||
|
||||
// Builds a tree entry with a grocery store and a SHA that points to the desired
|
||||
|
||||
@@ -7,11 +7,54 @@
|
||||
//
|
||||
|
||||
#import "GCYGroceryItem.h"
|
||||
#import "GCYGroceryStore.h"
|
||||
|
||||
SpecBegin(GCYGroceryItem)
|
||||
|
||||
it(@"should fail", ^{
|
||||
expect(YES).to.beFalsy();
|
||||
__block GCYGroceryStore *store;
|
||||
|
||||
__block NSString *list;
|
||||
__block NSSet *items;
|
||||
|
||||
beforeEach(^{
|
||||
store = [GCYGroceryStore modelWithDictionary:@{
|
||||
@"name": @"Friendly Neighborhood Grocery Store",
|
||||
} error:NULL];
|
||||
|
||||
list = @"~Crackers~\nBread\nPeanut butter";
|
||||
items = [NSSet setWithArray:@[
|
||||
[GCYGroceryItem modelWithDictionary:@{
|
||||
@"name": @"Bread",
|
||||
@"stores": [NSSet setWithObject:store],
|
||||
@"inCart": @NO
|
||||
} error:NULL],
|
||||
|
||||
[GCYGroceryItem modelWithDictionary:@{
|
||||
@"name": @"Crackers",
|
||||
@"stores": [NSSet setWithObject:store],
|
||||
@"inCart": @YES
|
||||
} error:NULL],
|
||||
|
||||
[GCYGroceryItem modelWithDictionary:@{
|
||||
@"name": @"Peanut butter",
|
||||
@"stores": [NSSet setWithObject:store],
|
||||
@"inCart": @NO
|
||||
} error:NULL],
|
||||
]];
|
||||
});
|
||||
|
||||
it(@"should parse a list of items", ^{
|
||||
// Verify that a trailing newline doesn't affect the list contents.
|
||||
list = [list stringByAppendingString:@"\n"];
|
||||
|
||||
NSArray *parsedItems = [[GCYGroceryItem groceryItemsWithString:list store:store] array];
|
||||
expect(parsedItems).notTo.beNil();
|
||||
expect([NSSet setWithArray:parsedItems]).to.equal(items);
|
||||
});
|
||||
|
||||
it(@"should serialize items into a list", ^{
|
||||
NSString *serializedList = [[GCYGroceryItem stringWithGroceryItems:items] first];
|
||||
expect(serializedList).to.equal(list);
|
||||
});
|
||||
|
||||
SpecEnd
|
||||
|
||||
44
GroceryListTests/GCYGroceryStoreSpec.m
Normal file
44
GroceryListTests/GCYGroceryStoreSpec.m
Normal file
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// GCYGroceryStoreSpec.m
|
||||
// GroceryList
|
||||
//
|
||||
// Created by Justin Spahr-Summers on 2013-12-22.
|
||||
// Copyright (c) 2013 Justin Spahr-Summers. All rights reserved.
|
||||
//
|
||||
|
||||
#import "GCYGroceryStore.h"
|
||||
|
||||
SpecBegin(GCYGroceryStore)
|
||||
|
||||
NSString *blobSHA = @"deadbeef";
|
||||
|
||||
__block OCTTreeEntry *entry;
|
||||
__block GCYGroceryStore *store;
|
||||
|
||||
beforeEach(^{
|
||||
entry = [OCTTreeEntry modelWithDictionary:@{
|
||||
@"path": @"Neighborhood Store",
|
||||
@"type": @(OCTTreeEntryTypeBlob),
|
||||
@"mode": @(OCTTreeEntryModeFile),
|
||||
@"SHA": blobSHA
|
||||
} error:NULL];
|
||||
|
||||
store = [GCYGroceryStore modelWithDictionary:@{
|
||||
@"name": @"Neighborhood Store",
|
||||
} error:NULL];
|
||||
|
||||
expect(entry).notTo.beNil();
|
||||
expect(store).notTo.beNil();
|
||||
});
|
||||
|
||||
it(@"should instantiate from a tree entry", ^{
|
||||
GCYGroceryStore *createdStore = [[GCYGroceryStore groceryStoreWithTreeEntry:entry] first];
|
||||
expect(createdStore).to.equal(store);
|
||||
});
|
||||
|
||||
it(@"should create a tree entry with a given SHA", ^{
|
||||
OCTTreeEntry *createdEntry = [[store treeEntryWithBlobSHA:blobSHA] first];
|
||||
expect(createdEntry).to.equal(entry);
|
||||
});
|
||||
|
||||
SpecEnd
|
||||
Reference in New Issue
Block a user