Expand test coverage and fix situations where requests would unexpectedly initialize incorrectly without error

* RKObjectParameterization now returns an empty dictionary if mapping produces an unmappable representation error (no mappable attributes/relationships found)
* Log errors if request construction results in an NSError and return nil
* Ensure errors are passed back up through object parameterization instead of just returning nil
* Reset the serialization MIME Type registry during RKTestFactory set up to ensure it is in a sane state
* Convert Hamcrest matchers to Expecta in the object mapper tests to fix infinite recursion on test failure (will need to completely phase out Hamcrest soon)
This commit is contained in:
Blake Watters
2012-10-05 19:16:55 -04:00
parent b9b34bf3dd
commit 877ce255b5
11 changed files with 111 additions and 52 deletions

View File

@@ -22,11 +22,11 @@
typedef UInt32 RKMappingErrorCode;
enum {
RKMappingErrorNotFound = 1001, // No mapping found
RKMappingErrorTypeMismatch = 1002, // Target class and object mapping are in disagreement
RKMappingErrorUnmappableContent = 1003, // No mappable attributes or relationships were found
RKMappingErrorFromMappingResult = 1004, // The error was returned from the mapping result
RKMappingErrorValidationFailure = 1005 // Generic error code for use when constructing validation errors
RKMappingErrorNotFound = 1001, // No mapping found
RKMappingErrorTypeMismatch = 1002, // Target class and object mapping are in disagreement
RKMappingErrorUnmappableRepresentation = 1003, // No values were found at the key paths of any attribute or relationship mappings in the given representation
RKMappingErrorFromMappingResult = 1004, // The error was returned from the mapping result
RKMappingErrorValidationFailure = 1005 // Generic error code for use when constructing validation errors
};
extern NSString * const RKMappingErrorKeyPathErrorKey; // The key path the error is associated with

View File

@@ -604,8 +604,9 @@ NSDate *RKDateFromStringWithFormatters(NSString *dateString, NSArray *formatters
RKLogError(@"Failed mapping operation: %@", [self.error localizedDescription]);
} else {
// We did not find anything to do
RKLogDebug(@"Mapping operation did not find any mappable content");
self.error = [NSError errorWithDomain:RKErrorDomain code:RKMappingErrorUnmappableContent userInfo:nil];
RKLogDebug(@"Mapping operation did not find any mappable values for the attribute and relationship mappings in the given object representation");
NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: @"No mappable values found for any of the attributes or relationship mappings" };
self.error = [NSError errorWithDomain:RKErrorDomain code:RKMappingErrorUnmappableRepresentation userInfo:userInfo];
}
}