@@ -151,16 +151,21 @@ - (void)testSerializeComplex {
151
151
newAuthor.firstName = @" Karl" ;
152
152
newAuthor.lastName = @" Armstrong" ;
153
153
154
- CommentResource *newComment = [[CommentResource alloc ] init ];
155
- newComment.ID = [NSUUID UUID ];
156
- newComment.author = newAuthor;
157
- newComment.text = @" First!" ;
154
+ CommentResource *firstComment = [[CommentResource alloc ] init ];
155
+ firstComment.ID = [NSUUID UUID ];
156
+ firstComment.author = newAuthor;
157
+ firstComment.text = @" First!" ;
158
+
159
+ CommentResource *secondComment = [[CommentResource alloc ] init ];
160
+ secondComment.ID = [NSUUID UUID ];
161
+ secondComment.author = newAuthor;
162
+ secondComment.text = @" Second!" ;
158
163
159
164
ArticleResource *newArticle = [[ArticleResource alloc ] init ];
160
165
newArticle.title = @" Title" ;
161
166
newArticle.author = newAuthor;
162
167
newArticle.date = [NSDate date ];
163
- newArticle.comments = [[NSArray alloc ] initWithObjects: newComment , nil ];
168
+ newArticle.comments = [[NSArray alloc ] initWithObjects: firstComment, secondComment , nil ];
164
169
165
170
NSDictionary *json = [JSONAPIResourceParser dictionaryFor: newArticle];
166
171
XCTAssertEqualObjects (json[@" type" ], @" articles" , @" Did not create Article!" );
@@ -171,8 +176,8 @@ - (void)testSerializeComplex {
171
176
XCTAssertNil (json[@" relationships" ][@" author" ][@" first-name" ], @" Bad link!" );
172
177
173
178
XCTAssertNotNil (json[@" relationships" ][@" comments" ], @" Did not create links!" );
174
- XCTAssertTrue ([json[@" relationships" ][@" comments" ] isKindOfClass: [NSArray class ]], @" Comments should be array!." );
175
- XCTAssertEqual ([json[@" relationships" ][@" comments" ] count ], 1 , @" Comments should have 1 element!." );
179
+ XCTAssertTrue ([json[@" relationships" ][@" comments" ][ @" data " ] isKindOfClass: [NSArray class ]], @" Comments should be array!." );
180
+ XCTAssertEqual ([json[@" relationships" ][@" comments" ][ @" data " ] count ], 2 , @" Comments should have 1 element!." );
176
181
}
177
182
178
183
- (void )testCreate {
@@ -226,11 +231,11 @@ - (void)testGenericSerialization {
226
231
NSDictionary *serializedFirstPost = [JSONAPIResourceParser dictionaryFor: posts.firstObject];
227
232
NSDictionary *serializedSecondPost = [JSONAPIResourceParser dictionaryFor: posts.lastObject];
228
233
229
- XCTAssertNotNil (serializedFirstPost[@" relationships" ][@" attachments" ][0 ], @" Media attachment should not be nil" );
230
- XCTAssertNotNil (serializedFirstPost[@" relationships" ][@" attachments" ][1 ], @" Web page url attachment should not be nil" );
234
+ XCTAssertNotNil (serializedFirstPost[@" relationships" ][@" attachments" ][@" data " ][ 0 ], @" Media attachment should not be nil" );
235
+ XCTAssertNotNil (serializedFirstPost[@" relationships" ][@" attachments" ][@" data " ][ 1 ], @" Web page url attachment should not be nil" );
231
236
232
- XCTAssertEqualObjects (serializedFirstPost[@" relationships" ][@" attachments" ][0 ][ @" data" ][@" id" ], @15 , @" Media id should be '15'" );
233
- XCTAssertEqualObjects (serializedFirstPost[@" relationships" ][@" attachments" ][0 ][ @" data" ][@" type" ], @" Media" , @" Media type should be 'Media'" );
237
+ XCTAssertEqualObjects (serializedFirstPost[@" relationships" ][@" attachments" ][@" data" ][ 0 ][@" id" ], @15 , @" Media id should be '15'" );
238
+ XCTAssertEqualObjects (serializedFirstPost[@" relationships" ][@" attachments" ][@" data" ][ 0 ][@" type" ], @" Media" , @" Media type should be 'Media'" );
234
239
235
240
XCTAssertEqualObjects (serializedFirstPost[@" relationships" ][@" publisher" ][@" data" ][@" id" ], @45 , @" User id should be '45'" );
236
241
XCTAssertEqualObjects (serializedFirstPost[@" relationships" ][@" publisher" ][@" data" ][@" type" ], @" User" , @" User type should be 'User'" );
0 commit comments