Skip to content

Commit

Permalink
Added support for easy setup with OCTest
Browse files Browse the repository at this point in the history
  • Loading branch information
casademora committed Dec 29, 2011
1 parent 6b4ef06 commit 2209c3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions Source/MagicalRecordHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ typedef void (^CoreDataBlock)(NSManagedObjectContext *context);
+ (SEL) errorHandlerAction;
+ (id) errorHandlerTarget;

+ (void) setDefaultModelForTestCase:(Class)class;
+ (void) setDefaultModelNamed:(NSString *)modelName;
+ (NSString *) defaultStoreName;

Expand Down
8 changes: 8 additions & 0 deletions Source/MagicalRecordHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ + (void) defaultErrorHandler:(NSError *)error
MRLog(@"Error: %@", detailedError);
}
}
MRLog(@"Error Message: %@", [error localizedDescription]);
MRLog(@"Error Domain: %@", [error domain]);
MRLog(@"Recovery Suggestion: %@", [error localizedRecoverySuggestion]);
}
Expand Down Expand Up @@ -126,6 +127,13 @@ + (void) setDefaultModelNamed:(NSString *)modelName;
[NSManagedObjectModel MR_setDefaultManagedObjectModel:model];
}

+ (void) setDefaultModelForTestCase:(Class)class;
{
NSBundle *bundle = [NSBundle bundleForClass:class];
NSManagedObjectModel *model = [NSManagedObjectModel mergedModelFromBundles:[NSArray arrayWithObject:bundle]];
[NSManagedObjectModel MR_setDefaultManagedObjectModel:model];
}

+ (NSString *) defaultStoreName;
{
NSString *defaultName = [[[NSBundle mainBundle] infoDictionary] valueForKey:(id)kCFBundleNameKey];
Expand Down

0 comments on commit 2209c3e

Please sign in to comment.