Permalink
Browse files

Fix a minor issue with the shorthand aliases, and add some tests arou…

…nd that
  • Loading branch information...
1 parent 2aed2fa commit a4c59b55c9be1093812818330705806e96d7a654 @tonyarnold tonyarnold committed Jan 29, 2016
@@ -191,6 +191,10 @@
9004F5681A94CC0E00A61312 /* MagicalRecord.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 905D073B1A63DE690076B54E /* MagicalRecord.framework */; };
9004F57A1A94D7D300A61312 /* MagicalRecord.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 905D07181A63DE190076B54E /* MagicalRecord.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9004F57D1A94D7F100A61312 /* MagicalRecord.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 905D073B1A63DE690076B54E /* MagicalRecord.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
+ 9007B14A1C5A416500C64F94 /* MagicalRecord+ShorthandTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9007B1491C5A416500C64F94 /* MagicalRecord+ShorthandTests.m */; };
+ 9007B14B1C5A416500C64F94 /* MagicalRecord+ShorthandTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9007B1491C5A416500C64F94 /* MagicalRecord+ShorthandTests.m */; };
+ 9007B14C1C5A416500C64F94 /* MagicalRecord+ShorthandTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9007B1491C5A416500C64F94 /* MagicalRecord+ShorthandTests.m */; };
+ 9007B14D1C5A416500C64F94 /* MagicalRecord+ShorthandTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9007B1491C5A416500C64F94 /* MagicalRecord+ShorthandTests.m */; };
90171E1B17C329CC00E7084A /* FixtureHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = C7CF9B6C17498B5C008D9D13 /* FixtureHelpers.m */; };
90171E1C17C329CD00E7084A /* FixtureHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = C7CF9B6C17498B5C008D9D13 /* FixtureHelpers.m */; };
90171E1D17C32ACE00E7084A /* TestModel.xcdatamodeld in Resources */ = {isa = PBXBuildFile; fileRef = 9099490817C2F3D400BC2B5C /* TestModel.xcdatamodeld */; };
@@ -637,6 +641,7 @@
581ECBF6187F660B00084FEE /* MultipleEntitiesWithNoPrimaryKey.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = MultipleEntitiesWithNoPrimaryKey.json; path = Fixtures/MultipleEntitiesWithNoPrimaryKey.json; sourceTree = "<group>"; };
9004F5211A94CBCF00A61312 /* MagicalRecord for iOS Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "MagicalRecord for iOS Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
9004F5661A94CBF900A61312 /* MagicalRecord for OS X Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "MagicalRecord for OS X Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 9007B1491C5A416500C64F94 /* MagicalRecord+ShorthandTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MagicalRecord+ShorthandTests.m"; sourceTree = "<group>"; };
9021D9E11AFB34D6001C80BA /* MagicalRecordTestHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MagicalRecordTestHelpers.h; path = Tests/Support/MagicalRecordTestHelpers.h; sourceTree = SOURCE_ROOT; };
9021D9E21AFB34D6001C80BA /* MagicalRecordTestHelpers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MagicalRecordTestHelpers.m; path = Tests/Support/MagicalRecordTestHelpers.m; sourceTree = SOURCE_ROOT; };
902CE11E18F6133E0024F47C /* MagicalRecordDeprecationMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MagicalRecordDeprecationMacros.h; sourceTree = "<group>"; };
@@ -1059,6 +1064,7 @@
children = (
902CE13718F61E170024F47C /* Abstract */,
902CE12B18F61A2F0024F47C /* MagicalRecord+ActionsTests.m */,
+ 9007B1491C5A416500C64F94 /* MagicalRecord+ShorthandTests.m */,
C7CF976817498275008D9D13 /* MagicalRecord+StackTests.m */,
90AA771718F79A3300D49377 /* NSManagedObject+MagicalRecordTests.m */,
9BB566931A2C47B3004174B3 /* NSManagedObjectContext+ChainSaveTests.m */,
@@ -1721,6 +1727,7 @@
9004F4F71A94CBCF00A61312 /* ImportMultipleEntitiesWithNoPrimaryKeyTests.m in Sources */,
9004F4F81A94CBCF00A61312 /* ImportSingleEntityRelatedToMappedEntityWithNestedMappedAttributesTests.m in Sources */,
9004F4F91A94CBCF00A61312 /* NSPersistentStoreCoordinatorHelperTests.m in Sources */,
+ 9007B14A1C5A416500C64F94 /* MagicalRecord+ShorthandTests.m in Sources */,
9004F4FA1A94CBCF00A61312 /* NSManagedObjectContextHelperTests.m in Sources */,
9004F4FB1A94CBCF00A61312 /* ImportSingleEntityRelatedToMappedEntityUsingMappedPrimaryKeyTests.m in Sources */,
9004F4FC1A94CBCF00A61312 /* _SingleEntityWithNoRelationships.m in Sources */,
@@ -1773,6 +1780,7 @@
9004F53C1A94CBF900A61312 /* ImportMultipleEntitiesWithNoPrimaryKeyTests.m in Sources */,
9004F53D1A94CBF900A61312 /* ImportSingleEntityRelatedToMappedEntityWithNestedMappedAttributesTests.m in Sources */,
9004F53E1A94CBF900A61312 /* NSPersistentStoreCoordinatorHelperTests.m in Sources */,
+ 9007B14B1C5A416500C64F94 /* MagicalRecord+ShorthandTests.m in Sources */,
9004F53F1A94CBF900A61312 /* NSManagedObjectContextHelperTests.m in Sources */,
9004F5401A94CBF900A61312 /* ImportSingleEntityRelatedToMappedEntityUsingMappedPrimaryKeyTests.m in Sources */,
9004F5411A94CBF900A61312 /* _SingleEntityWithNoRelationships.m in Sources */,
@@ -1961,6 +1969,7 @@
581ECBF9187F663100084FEE /* ImportMultipleEntitiesWithNoPrimaryKeyTests.m in Sources */,
90542E1A1864688100916224 /* ImportSingleEntityRelatedToMappedEntityWithNestedMappedAttributesTests.m in Sources */,
90542E2618648AAF00916224 /* NSPersistentStoreCoordinatorHelperTests.m in Sources */,
+ 9007B14C1C5A416500C64F94 /* MagicalRecord+ShorthandTests.m in Sources */,
90542E201864855500916224 /* NSManagedObjectContextHelperTests.m in Sources */,
90542E1C1864691E00916224 /* ImportSingleEntityRelatedToMappedEntityUsingMappedPrimaryKeyTests.m in Sources */,
9099494B17C2F42100BC2B5C /* _SingleEntityWithNoRelationships.m in Sources */,
@@ -2013,6 +2022,7 @@
581ECBFA187F663200084FEE /* ImportMultipleEntitiesWithNoPrimaryKeyTests.m in Sources */,
90542E1B1864688100916224 /* ImportSingleEntityRelatedToMappedEntityWithNestedMappedAttributesTests.m in Sources */,
90542E2718648AB000916224 /* NSPersistentStoreCoordinatorHelperTests.m in Sources */,
+ 9007B14D1C5A416500C64F94 /* MagicalRecord+ShorthandTests.m in Sources */,
90542E211864855500916224 /* NSManagedObjectContextHelperTests.m in Sources */,
90542E1D1864691E00916224 /* ImportSingleEntityRelatedToMappedEntityUsingMappedPrimaryKeyTests.m in Sources */,
9099494C17C2F42100BC2B5C /* _SingleEntityWithNoRelationships.m in Sources */,
@@ -89,8 +89,7 @@ static BOOL MRAddShorthandMethodForPrefixedInstanceMethod(Class objectClass, SEL
{
NSString *originalSelectorString = NSStringFromSelector(originalSelector);
- if ([originalSelectorString hasPrefix:prefix] == NO &&
- ([originalSelectorString hasPrefix:@"_"] || [originalSelectorString hasPrefix:@"init"]))
+ if ([originalSelectorString hasPrefix:prefix] == NO)
{
NSString *prefixedSelector = [prefix stringByAppendingString:originalSelectorString];
Method existingMethod = class_getInstanceMethod(objectClass, NSSelectorFromString(prefixedSelector));
@@ -0,0 +1,35 @@
+//
+// Created by Tony Arnold on 28/01/2016.
+// Copyright © 2016 Magical Panda Software LLC. All rights reserved.
+
+#import "MagicalRecordTestBase.h"
+#import "NSManagedObject+MagicalRecord.h"
+#import "MagicalRecord+ShorthandMethods.h"
+#import "MagicalRecordShorthandMethodAliases.h"
+
+@interface MagicalRecordShorthandTests : MagicalRecordTestBase
+
+@end
+
+@implementation MagicalRecordShorthandTests
+
+- (void)setUp
+{
+ [super setUp];
+ [MagicalRecord enableShorthandMethods];
+}
+
+- (void)testLongFormMethodsAreStillAvailableWhenShorthandIsEnabled
+{
+ expect([NSManagedObjectContext class]).to.respondTo(@selector(MR_rootSavingContext));
+ expect([NSManagedObjectContext MR_rootSavingContext]).to.respondTo(@selector(MR_saveWithBlock:));
+}
+
+- (void)testShorthandMethodsAreAvailableWhenEnabled
+{
+ expect([NSManagedObjectContext class]).to.respondTo(@selector(rootSavingContext));
+ expect([NSManagedObjectContext rootSavingContext]).toNot.beNil();
+ expect([NSManagedObjectContext rootSavingContext]).to.respondTo(@selector(saveWithBlock:));
+}
+
+@end

0 comments on commit a4c59b5

Please sign in to comment.