@@ -81,7 +81,7 @@ -(void)testBrokenJSON
8181 STAssertTrue (err.code == kJSONModelErrorBadJSON , @" Wrong error for missing keys" );
8282}
8383
84- - (void )performTestErrorsInNestedModelFile : (NSString *)jsonFilename
84+ - (NSError * )performTestErrorsInNestedModelFile : (NSString *)jsonFilename
8585{
8686 NSString * filePath = [[NSBundle bundleForClass:[JSONModel class]] .resourcePath stringByAppendingPathComponent:jsonFilename];
8787 NSString * jsonContents = [NSString stringWithContentsOfFile: filePath encoding: NSUTF8StringEncoding error: nil ];
@@ -96,17 +96,24 @@ - (void)performTestErrorsInNestedModelFile:(NSString*)jsonFilename
9696 STAssertTrue (err.code == kJSONModelErrorInvalidData , @" Wrong error for missing keys" );
9797
9898 // Make sure that 'name' is listed as the missing key
99- STAssertTrue ([err.userInfo[kJSONModelMissingKeys ][0 ] isEqualToString: @" name" ], @" 'name' should be the missing key." );
99+ STAssertEqualObjects (err.userInfo [kJSONModelMissingKeys ][0 ], @" name" , @" 'name' should be the missing key." );
100+ return err;
100101}
101102
102103-(void )testErrorsInNestedModelsArray
103104{
104- [self performTestErrorsInNestedModelFile: @" nestedDataWithArrayError.json" ];
105+ NSError * err = [self performTestErrorsInNestedModelFile: @" nestedDataWithArrayError.json" ];
106+
107+ // Make sure that the error is at the expected key-path
108+ STAssertEqualObjects (err.userInfo [kJSONModelKeyPath ], @" images[1]" , @" kJSONModelKeyPath does not contain the path of the error." );
105109}
106110
107111-(void )testErrorsInNestedModelsDictionary
108112{
109- [self performTestErrorsInNestedModelFile: @" nestedDataWithDictionaryError.json" ];
113+ NSError * err = [self performTestErrorsInNestedModelFile: @" nestedDataWithDictionaryError.json" ];
114+
115+ // Make sure that the error is at the expected key-path
116+ STAssertEqualObjects (err.userInfo [kJSONModelKeyPath ], @" imageObject.image2" , @" kJSONModelKeyPath does not contain the path of the error." );
110117}
111118
112119-(void )testForNilInputFromString
0 commit comments