mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 04:20:21 +08:00
Get RestKit specs running & passing.
This commit is contained in:
@@ -165,15 +165,15 @@
|
||||
259569D5126DF464004BAC4C /* UISpec_1_0.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 250BC51011F62D6B00F3FE5A /* UISpec_1_0.a */; };
|
||||
25957826126E3BE9004BAC4C /* RKRailsRouterSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 25957825126E3BE9004BAC4C /* RKRailsRouterSpec.m */; };
|
||||
25A5B4E912762249003DC8A4 /* blake.png in Resources */ = {isa = PBXBuildFile; fileRef = 25A5B4E812762249003DC8A4 /* blake.png */; };
|
||||
25E0774D1279E64500B22EC9 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25E075981279D9AB00B22EC9 /* MobileCoreServices.framework */; };
|
||||
3F032A7910FFB89100F35142 /* RKCat.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F032A7810FFB89100F35142 /* RKCat.m */; };
|
||||
3F032AA810FFBBCD00F35142 /* RKHouse.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F032AA710FFBBCD00F35142 /* RKHouse.m */; };
|
||||
3F032AAB10FFBC1F00F35142 /* RKResident.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F032AAA10FFBC1F00F35142 /* RKResident.m */; };
|
||||
3F1912A712DF6B4800C077AD /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F19129712DF6B4800C077AD /* CFNetwork.framework */; };
|
||||
3F1912AF12DF6B6200C077AD /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25E075981279D9AB00B22EC9 /* MobileCoreServices.framework */; };
|
||||
3F6C3A2E10FE749C008F47C5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F6C3A2D10FE749C008F47C5 /* Foundation.framework */; };
|
||||
3F6C3A9410FE7519008F47C5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F6C3A9310FE7519008F47C5 /* main.m */; };
|
||||
3F6C3A9610FE7524008F47C5 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F6C3A9510FE7524008F47C5 /* UIKit.framework */; };
|
||||
7377FBE21268E96300868752 /* RKManagedObjectCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 7377FBE11268E96300868752 /* RKManagedObjectCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
73C89EF112A5BB9A000FE600 /* RKReachabilityObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = 73C89EF012A5BB9A000FE600 /* RKReachabilityObserver.m */; };
|
||||
73C89EF212A5BB9A000FE600 /* RKReachabilityObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 73C89EEF12A5BB9A000FE600 /* RKReachabilityObserver.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
73C89EF312A5BB9A000FE600 /* RKReachabilityObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = 73C89EF012A5BB9A000FE600 /* RKReachabilityObserver.m */; };
|
||||
73FE56C7126CB91600E0F30B /* RKURL.h in Headers */ = {isa = PBXBuildFile; fileRef = 73FE56C4126CB91600E0F30B /* RKURL.h */; };
|
||||
@@ -335,6 +335,13 @@
|
||||
remoteGlobalIDString = C7D4F29310BDA39C00B00019;
|
||||
remoteInfo = Specs;
|
||||
};
|
||||
3F4BC8F212DE4C7F00048E71 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 2523360411E79F090048F9B4;
|
||||
remoteInfo = RestKitThree20;
|
||||
};
|
||||
73FE56A8126CB83400E0F30B /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
|
||||
@@ -571,6 +578,8 @@
|
||||
3F032AA710FFBBCD00F35142 /* RKHouse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKHouse.m; sourceTree = "<group>"; };
|
||||
3F032AA910FFBC1F00F35142 /* RKResident.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKResident.h; sourceTree = "<group>"; };
|
||||
3F032AAA10FFBC1F00F35142 /* RKResident.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKResident.m; sourceTree = "<group>"; };
|
||||
3F19126812DF6B3200C077AD /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
|
||||
3F19129712DF6B4800C077AD /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
|
||||
3F6C39A510FE5C95008F47C5 /* UISpec.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UISpec.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
3F6C39A710FE5C95008F47C5 /* UISpec-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "UISpec-Info.plist"; sourceTree = "<group>"; };
|
||||
3F6C39B610FE738A008F47C5 /* UISpec.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = UISpec.xcodeproj; path = /Users/blake/Projects/two_toasters/InMotion/Libraries/UISpec/xcode/UISpec/UISpec.xcodeproj; sourceTree = "<absolute>"; };
|
||||
@@ -652,7 +661,8 @@
|
||||
25956986126DF1AE004BAC4C /* libRestKitObjectMapping.a in Frameworks */,
|
||||
25956987126DF1AE004BAC4C /* libRestKitSupport.a in Frameworks */,
|
||||
259569D5126DF464004BAC4C /* UISpec_1_0.a in Frameworks */,
|
||||
25E0774D1279E64500B22EC9 /* MobileCoreServices.framework in Frameworks */,
|
||||
3F1912A712DF6B4800C077AD /* CFNetwork.framework in Frameworks */,
|
||||
3F1912AF12DF6B6200C077AD /* MobileCoreServices.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -683,6 +693,8 @@
|
||||
2590E6711252357200531FA8 /* Vendor */,
|
||||
0867D69AFE84028FC02AAC07 /* Frameworks */,
|
||||
034768DFFF38A50411DB9C8B /* Products */,
|
||||
3F19126812DF6B3200C077AD /* CoreFoundation.framework */,
|
||||
3F19129712DF6B4800C077AD /* CFNetwork.framework */,
|
||||
);
|
||||
name = OTRestFramework;
|
||||
sourceTree = "<group>";
|
||||
@@ -1428,6 +1440,7 @@
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
3F4BC8F312DE4C7F00048E71 /* PBXTargetDependency */,
|
||||
25956982126DF182004BAC4C /* PBXTargetDependency */,
|
||||
);
|
||||
name = UISpec;
|
||||
@@ -1771,7 +1784,6 @@
|
||||
257EAAAF11F73DA000DB04C3 /* RKObjectSpec.m in Sources */,
|
||||
25957826126E3BE9004BAC4C /* RKRailsRouterSpec.m in Sources */,
|
||||
2524CB5D1278930200D1314C /* RKParamsAttachmentSpec.m in Sources */,
|
||||
73C89EF112A5BB9A000FE600 /* RKReachabilityObserver.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -1813,6 +1825,11 @@
|
||||
target = 25956956126DF0A8004BAC4C /* RestKit */;
|
||||
targetProxy = 25956981126DF182004BAC4C /* PBXContainerItemProxy */;
|
||||
};
|
||||
3F4BC8F312DE4C7F00048E71 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 2523360411E79F090048F9B4 /* RestKitThree20 */;
|
||||
targetProxy = 3F4BC8F212DE4C7F00048E71 /* PBXContainerItemProxy */;
|
||||
};
|
||||
73FE56A9126CB83400E0F30B /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 253A080B12551D3000976E89 /* RestKitSupport */;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
@"age", @"age",
|
||||
@"createdAt", @"created-at",
|
||||
@"updatedAt", @"updated-at",
|
||||
@"railsID", @"id",
|
||||
nil];
|
||||
}
|
||||
|
||||
@@ -35,4 +36,8 @@
|
||||
return @"/this/is/the/path";
|
||||
}
|
||||
|
||||
+ (NSString*)primaryKeyProperty {
|
||||
return @"railsID";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -18,44 +18,57 @@
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
* For these specs to run the rails app in Specs/restkitspecs_rails must be running.
|
||||
* cd Specs/restkitspecs_rails
|
||||
* rake db:create db:migrate
|
||||
* rake db:seed_fu
|
||||
* ./script/server
|
||||
*/
|
||||
|
||||
@implementation RKObjectManagerSpec
|
||||
|
||||
- (void)beforeAll {
|
||||
NSString* localBaseURL = [NSString stringWithFormat:@"http://%s:3000", getenv("RKREST_IP_ADDRESS")];
|
||||
_modelManager = [RKObjectManager objectManagerWithBaseURL:localBaseURL];
|
||||
NSString* localBaseURL = [NSString stringWithFormat:@"http://%s:3000", "localhost"]; //getenv("RKREST_IP_ADDRESS")
|
||||
NSLog(@"Local Base URL: %@", localBaseURL);
|
||||
_modelManager = [[RKObjectManager objectManagerWithBaseURL:localBaseURL] retain];
|
||||
_modelManager.objectStore = [[RKManagedObjectStore alloc] initWithStoreFilename:@"RKSpecs.sqlite"];
|
||||
[_modelManager registerClass:[RKHuman class] forElementNamed:@"human"];
|
||||
|
||||
_responseLoader = [[RKSpecResponseLoader alloc] init];
|
||||
}
|
||||
|
||||
- (void)itShouldDefaultToAnXMLMappingFormat {
|
||||
[expectThat(_modelManager.format) should:be(RKMappingFormatXML)];
|
||||
[expectThat(_modelManager.format) should:be(RKMappingFormatJSON)];
|
||||
}
|
||||
|
||||
- (void)itShouldSetTheAcceptHeaderAppropriatelyForTheFormat {
|
||||
_modelManager.format = RKMappingFormatXML;
|
||||
[expectThat([_modelManager.client.HTTPHeaders valueForKey:@"Accept"]) should:be(@"application/xml")];
|
||||
// TODO: re-enable when we implement XML support.
|
||||
// _modelManager.format = RKMappingFormatXML;
|
||||
// [expectThat([_modelManager.client.HTTPHeaders valueForKey:@"Accept"]) should:be(@"application/xml")];
|
||||
_modelManager.format = RKMappingFormatJSON;
|
||||
[expectThat([_modelManager.client.HTTPHeaders valueForKey:@"Accept"]) should:be(@"application/json")];
|
||||
}
|
||||
|
||||
- (void)itShouldHandleConnectionFailures {
|
||||
NSString* localBaseURL = [NSString stringWithFormat:@"http://%s:3001", getenv("RKREST_IP_ADDRESS")];
|
||||
RKObjectManager* modelManager = [RKObjectManager managerWithBaseURL:localBaseURL];
|
||||
[modelManager loadResource:@"/humans/1" delegate:_responseLoader];
|
||||
RKObjectManager* modelManager = [RKObjectManager objectManagerWithBaseURL:localBaseURL];
|
||||
[modelManager loadObjectsAtResourcePath:@"/humans/1" delegate:_responseLoader];
|
||||
[_responseLoader waitForResponse];
|
||||
[expectThat(_responseLoader.success) should:be(NO)];
|
||||
}
|
||||
|
||||
- (void)itShouldLoadAHuman {
|
||||
[_modelManager loadResource:@"/humans/1" delegate:_responseLoader];
|
||||
NSLog(@"Model manager baase url: %@", [_modelManager.client baseURL]);
|
||||
[_modelManager loadObjectsAtResourcePath:@"/humans/1" delegate:_responseLoader];
|
||||
[_responseLoader waitForResponse];
|
||||
RKHuman* blake = (RKHuman*) _responseLoader.response;
|
||||
RKHuman* blake = (RKHuman*)[_responseLoader.response objectAtIndex:0];;
|
||||
NSLog(@"Blake: %@", blake);
|
||||
[expectThat(blake.name) should:be(@"Blake Watters")];
|
||||
}
|
||||
|
||||
- (void)itShouldLoadAllHumans {
|
||||
[_modelManager loadResource:@"/humans" delegate:_responseLoader];
|
||||
[_modelManager loadObjectsAtResourcePath:@"/humans" delegate:_responseLoader];
|
||||
[_responseLoader waitForResponse];
|
||||
NSArray* humans = (NSArray*) _responseLoader.response;
|
||||
[expectThat([humans count]) should:be(4)];
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
|
||||
@interface RKObjectMapperSpec : NSObject <UISpec>
|
||||
|
||||
- (NSString*)jsonString;
|
||||
- (NSString*)jsonCollectionString;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RKObjectMapperSpec
|
||||
@@ -26,7 +29,7 @@
|
||||
[mapper registerClass:[RKMappableObject class] forElementNamed:@"test_serialization_class"];
|
||||
[mapper registerClass:[RKMappableAssociation class] forElementNamed:@"has_many"];
|
||||
[mapper registerClass:[RKMappableAssociation class] forElementNamed:@"has_one"];
|
||||
id result = [mapper buildModelFromString:[self jsonString]];
|
||||
id result = [mapper mapFromString:[self jsonString]];
|
||||
|
||||
[expectThat(result) shouldNot:be(nil)];
|
||||
[expectThat([result dateTest]) shouldNot:be(nil)];
|
||||
@@ -47,7 +50,9 @@
|
||||
[mapper registerClass:[RKMappableObject class] forElementNamed:@"test_serialization_class"];
|
||||
[mapper registerClass:[RKMappableAssociation class] forElementNamed:@"has_many"];
|
||||
[mapper registerClass:[RKMappableAssociation class] forElementNamed:@"has_one"];
|
||||
NSArray* results = [mapper buildModelsFromString:[self jsonCollectionString]];
|
||||
NSString* collectionString = [self jsonCollectionString];
|
||||
NSArray* results = [mapper mapFromString:collectionString];
|
||||
NSLog(@"Results: %@", results);
|
||||
[expectThat([results count]) should:be(2)];
|
||||
|
||||
RKMappableObject* result = (RKMappableObject*) [results objectAtIndex:0];
|
||||
@@ -63,54 +68,55 @@
|
||||
[expectThat([[result hasMany] count]) should:be(2)];
|
||||
}
|
||||
|
||||
- (void)itShouldMapFromXML {
|
||||
RKObjectMapper* mapper = [[RKObjectMapper alloc] init];
|
||||
mapper.format = RKMappingFormatXML;
|
||||
[mapper registerClass:[RKMappableObject class] forElementNamed:@"test_serialization_class"];
|
||||
[mapper registerClass:[RKMappableObject class] forElementNamed:@"test_serialization_class"];
|
||||
[mapper registerClass:[RKMappableAssociation class] forElementNamed:@"has_many"];
|
||||
[mapper registerClass:[RKMappableAssociation class] forElementNamed:@"has_one"];
|
||||
id result = [mapper buildModelFromString:[self xmlString]];
|
||||
|
||||
[expectThat(result) shouldNot:be(nil)];
|
||||
[expectThat([result dateTest]) shouldNot:be(nil)];
|
||||
[expectThat([result numberTest]) should:be(2)];
|
||||
[expectThat([result stringTest]) should:be(@"SomeString")];
|
||||
|
||||
[expectThat([result hasOne]) shouldNot:be(nil)];
|
||||
[expectThat([[result hasOne] testString]) should:be(@"A String")];
|
||||
|
||||
[expectThat([result hasMany]) shouldNot:be(nil)];
|
||||
[expectThat([[result hasMany] count]) should:be(2)];
|
||||
}
|
||||
|
||||
- (void)itShouldMapObjectsFromXML {
|
||||
RKObjectMapper* mapper = [[RKObjectMapper alloc] init];
|
||||
mapper.format = RKMappingFormatXML;
|
||||
[mapper registerClass:[RKMappableObject class] forElementNamed:@"test_serialization_class"];
|
||||
[mapper registerClass:[RKMappableObject class] forElementNamed:@"test_serialization_class"];
|
||||
[mapper registerClass:[RKMappableAssociation class] forElementNamed:@"has_many"];
|
||||
[mapper registerClass:[RKMappableAssociation class] forElementNamed:@"has_one"];
|
||||
NSArray* results = [mapper buildModelsFromString:[self xmlCollectionString]];
|
||||
[expectThat([results count]) should:be(2)];
|
||||
|
||||
RKMappableObject* result = (RKMappableObject*) [results objectAtIndex:0];
|
||||
[expectThat(result) shouldNot:be(nil)];
|
||||
[expectThat([result dateTest]) shouldNot:be(nil)];
|
||||
[expectThat([result numberTest]) should:be(2)];
|
||||
[expectThat([result stringTest]) should:be(@"SomeString")];
|
||||
|
||||
[expectThat([result hasOne]) shouldNot:be(nil)];
|
||||
[expectThat([[result hasOne] testString]) should:be(@"A String")];
|
||||
|
||||
[expectThat([result hasMany]) shouldNot:be(nil)];
|
||||
[expectThat([[result hasMany] count]) should:be(2)];
|
||||
}
|
||||
// TODO: re-implement these specs when we re-implement xml parsing.
|
||||
//- (void)itShouldMapFromXML {
|
||||
// RKObjectMapper* mapper = [[RKObjectMapper alloc] init];
|
||||
// mapper.format = RKMappingFormatXML;
|
||||
// [mapper registerClass:[RKMappableObject class] forElementNamed:@"test_serialization_class"];
|
||||
// [mapper registerClass:[RKMappableObject class] forElementNamed:@"test_serialization_class"];
|
||||
// [mapper registerClass:[RKMappableAssociation class] forElementNamed:@"has_many"];
|
||||
// [mapper registerClass:[RKMappableAssociation class] forElementNamed:@"has_one"];
|
||||
// id result = [mapper mapFromString:[self xmlString]];
|
||||
//
|
||||
// [expectThat(result) shouldNot:be(nil)];
|
||||
// [expectThat([result dateTest]) shouldNot:be(nil)];
|
||||
// [expectThat([result numberTest]) should:be(2)];
|
||||
// [expectThat([result stringTest]) should:be(@"SomeString")];
|
||||
//
|
||||
// [expectThat([result hasOne]) shouldNot:be(nil)];
|
||||
// [expectThat([[result hasOne] testString]) should:be(@"A String")];
|
||||
//
|
||||
// [expectThat([result hasMany]) shouldNot:be(nil)];
|
||||
// [expectThat([[result hasMany] count]) should:be(2)];
|
||||
//}
|
||||
//
|
||||
//- (void)itShouldMapObjectsFromXML {
|
||||
// RKObjectMapper* mapper = [[RKObjectMapper alloc] init];
|
||||
// mapper.format = RKMappingFormatXML;
|
||||
// [mapper registerClass:[RKMappableObject class] forElementNamed:@"test_serialization_class"];
|
||||
// [mapper registerClass:[RKMappableObject class] forElementNamed:@"test_serialization_class"];
|
||||
// [mapper registerClass:[RKMappableAssociation class] forElementNamed:@"has_many"];
|
||||
// [mapper registerClass:[RKMappableAssociation class] forElementNamed:@"has_one"];
|
||||
// NSArray* results = [mapper mapFromString:[self xmlCollectionString]];
|
||||
// [expectThat([results count]) should:be(2)];
|
||||
//
|
||||
// RKMappableObject* result = (RKMappableObject*) [results objectAtIndex:0];
|
||||
// [expectThat(result) shouldNot:be(nil)];
|
||||
// [expectThat([result dateTest]) shouldNot:be(nil)];
|
||||
// [expectThat([result numberTest]) should:be(2)];
|
||||
// [expectThat([result stringTest]) should:be(@"SomeString")];
|
||||
//
|
||||
// [expectThat([result hasOne]) shouldNot:be(nil)];
|
||||
// [expectThat([[result hasOne] testString]) should:be(@"A String")];
|
||||
//
|
||||
// [expectThat([result hasMany]) shouldNot:be(nil)];
|
||||
// [expectThat([[result hasMany] count]) should:be(2)];
|
||||
//}
|
||||
|
||||
- (void)itShouldNotUpdateNilPropertyToNil {
|
||||
RKObjectMapperSpecModel* model = [[RKObjectMapperSpecModel alloc] autorelease];
|
||||
RKObjectMapper* mapper = [[RKObjectMapper alloc] init];
|
||||
[mapper updateObject:model ifNewPropertyValue:nil forPropertyNamed:@"name"];
|
||||
[mapper updateModel:model ifNewPropertyValue:nil forPropertyNamed:@"name"];
|
||||
|
||||
[expectThat(model.name) should:be(nil)];
|
||||
}
|
||||
@@ -119,7 +125,7 @@
|
||||
RKObjectMapperSpecModel* model = [[RKObjectMapperSpecModel alloc] autorelease];
|
||||
model.age = [NSNumber numberWithInt:0];
|
||||
RKObjectMapper* mapper = [[RKObjectMapper alloc] init];
|
||||
[mapper updateObject:model ifNewPropertyValue:nil forPropertyNamed:@"age"];
|
||||
[mapper updateModel:model ifNewPropertyValue:nil forPropertyNamed:@"age"];
|
||||
|
||||
[expectThat(model.age) should:be(nil)];
|
||||
}
|
||||
@@ -127,7 +133,7 @@
|
||||
- (void)itShouldBeAbleToSetNilPropertiesToNonNil {
|
||||
RKObjectMapperSpecModel* model = [[RKObjectMapperSpecModel alloc] autorelease];
|
||||
RKObjectMapper* mapper = [[RKObjectMapper alloc] init];
|
||||
[mapper updateObject:model ifNewPropertyValue:[NSNumber numberWithInt:0] forPropertyNamed:@"age"];
|
||||
[mapper updateModel:model ifNewPropertyValue:[NSNumber numberWithInt:0] forPropertyNamed:@"age"];
|
||||
|
||||
[expectThat(model.age) should:be([NSNumber numberWithInt:0])];
|
||||
}
|
||||
@@ -137,7 +143,7 @@
|
||||
RKObjectMapper* mapper = [[RKObjectMapper alloc] init];
|
||||
|
||||
model.name = @"Bob";
|
||||
[mapper updateObject:model ifNewPropertyValue:@"Will" forPropertyNamed:@"name"];
|
||||
[mapper updateModel:model ifNewPropertyValue:@"Will" forPropertyNamed:@"name"];
|
||||
[expectThat(model.name) should:be(@"Will")];
|
||||
}
|
||||
|
||||
@@ -146,7 +152,7 @@
|
||||
RKObjectMapper* mapper = [[RKObjectMapper alloc] init];
|
||||
|
||||
model.age = [NSNumber numberWithInt:16];
|
||||
[mapper updateObject:model ifNewPropertyValue:[NSNumber numberWithInt:17] forPropertyNamed:@"age"];
|
||||
[mapper updateModel:model ifNewPropertyValue:[NSNumber numberWithInt:17] forPropertyNamed:@"age"];
|
||||
[expectThat(model.age) should:be([NSNumber numberWithInt:17])];
|
||||
}
|
||||
|
||||
@@ -155,7 +161,7 @@
|
||||
RKObjectMapper* mapper = [[RKObjectMapper alloc] init];
|
||||
|
||||
model.createdAt = [NSDate date];
|
||||
[mapper updateObject:model ifNewPropertyValue:[NSDate dateWithTimeIntervalSince1970:0] forPropertyNamed:@"createdAt"];
|
||||
[mapper updateModel:model ifNewPropertyValue:[NSDate dateWithTimeIntervalSince1970:0] forPropertyNamed:@"createdAt"];
|
||||
[expectThat(model.createdAt) should:be([NSDate dateWithTimeIntervalSince1970:0])];
|
||||
}
|
||||
|
||||
@@ -192,8 +198,7 @@
|
||||
|
||||
- (NSString*)jsonCollectionString {
|
||||
return
|
||||
@"{"
|
||||
@" \"test_serialization_classes\":["
|
||||
@"["
|
||||
@" {"
|
||||
@" \"test_serialization_class\":{"
|
||||
@" \"date_test\":\"2009-08-17T19:24:40Z\","
|
||||
@@ -238,8 +243,8 @@
|
||||
@" ]"
|
||||
@" }"
|
||||
@" }"
|
||||
@" ]"
|
||||
@"}";
|
||||
@"]"
|
||||
@"";
|
||||
}
|
||||
|
||||
- (NSString*)xmlString {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
/**
|
||||
* This spec requires the test Sinatra server to be running
|
||||
* `ruby Specs/server.rb`
|
||||
*/
|
||||
- (void)itShouldSendMultiPartRequests {
|
||||
NSString* URLString = [NSString stringWithFormat:@"http://%s:4567/photo", getenv("RESTKIT_IP_ADDRESS")];
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
- (id)init {
|
||||
if (self = [super init]) {
|
||||
_timeout = 10;
|
||||
_timeout = 100;
|
||||
_awaitingResponse = NO;
|
||||
}
|
||||
|
||||
@@ -53,11 +53,13 @@
|
||||
_success = YES;
|
||||
}
|
||||
|
||||
- (void)resourceLoadRequest:(RKRequest*)request didLoadObjects:(NSArray*)objects response:(RKResponse*)response object:(id<RKObjectMappable>)object {
|
||||
[self loadResponse:response];
|
||||
- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects {
|
||||
NSLog(@"Response: %@", [objectLoader.response bodyAsString]);
|
||||
[self loadResponse:objects];
|
||||
}
|
||||
|
||||
- (void)resourceLoadRequest:(RKRequest*)request didFailWithError:(NSError*)error response:(RKResponse*)response object:(id<RKObjectMappable>)object {
|
||||
- (void)objectLoader:(RKObjectLoader*)objectLoader didFailWithError:(NSError*)error; {
|
||||
NSLog(@"Error: %@", error);
|
||||
_awaitingResponse = NO;
|
||||
_success = NO;
|
||||
_failureError = [error retain];
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user