Permalink
Browse files

Fix tests using `objectWithID:` against the root saving context

  • Loading branch information...
1 parent a2ddb92 commit 347319011ce87690420716e82ab240d3b590b570 @tonyarnold committed Aug 20, 2013
@@ -38,9 +38,11 @@
expect(objectId).toNot.beNil();
- NSManagedObject *fetchedObject = [[NSManagedObjectContext MR_rootSavingContext] objectRegisteredForID:objectId];
+ NSError *fetchError;
+ NSManagedObject *fetchedObject = [[NSManagedObjectContext MR_rootSavingContext] existingObjectWithID:objectId error:&fetchError];
expect(fetchedObject).toNot.beNil();
+ expect(fetchError).to.beNil();
expect([fetchedObject hasChanges]).to.beFalsy();
});
@@ -58,9 +60,11 @@
expect(objectId).toNot.beNil();
- NSManagedObject *fetchedObject = [[NSManagedObjectContext MR_defaultContext] objectWithID:objectId];
-
+ NSError *fetchError;
+ NSManagedObject *fetchedObject = [[NSManagedObjectContext MR_rootSavingContext] existingObjectWithID:objectId error:&fetchError];
+
expect(fetchedObject).toNot.beNil();
+ expect(fetchError).to.beNil();
expect([fetchedObject hasChanges]).to.beFalsy();
});
@@ -208,9 +212,11 @@
expect(objectId).toNot.beNil();
- NSManagedObject *fetchedObject = [[NSManagedObjectContext MR_rootSavingContext] objectRegisteredForID:objectId];
+ NSError *fetchError;
+ NSManagedObject *fetchedObject = [[NSManagedObjectContext MR_rootSavingContext] existingObjectWithID:objectId error:&fetchError];
expect(fetchedObject).toNot.beNil();
+ expect(fetchError).to.beNil();
expect([fetchedObject hasChanges]).to.beFalsy();
});
});
@@ -126,10 +126,12 @@
[managedObjectContext MR_saveToPersistentStoreAndWait];
- NSManagedObject *fetchedObject = [[NSManagedObjectContext MR_rootSavingContext] objectRegisteredForID:objectId];
+ NSError *fetchError;
+ NSManagedObject *fetchedObject = [[NSManagedObjectContext MR_rootSavingContext] existingObjectWithID:objectId error:&fetchError];
expect(fetchedObject).toNot.beNil();
- expect([fetchedObject hasChanges]).will.beFalsy();
+ expect(fetchError).to.beNil();
+ expect([fetchedObject hasChanges]).to.beFalsy();
});
});
@@ -220,8 +222,11 @@
expect(error).to.beNil();
}];
- NSManagedObject *fetchedObject = [[NSManagedObjectContext MR_rootSavingContext] objectRegisteredForID:permanentObjectID];
+ NSError *fetchError;
+ NSManagedObject *fetchedObject = [[NSManagedObjectContext MR_rootSavingContext] existingObjectWithID:permanentObjectID error:&fetchError];
+
expect(fetchedObject).toNot.beNil();
+ expect(fetchError).to.beNil();
expect([fetchedObject hasChanges]).to.beFalsy();
});
});

0 comments on commit 3473190

Please sign in to comment.