Created
September 21, 2011 19:13
-
-
Save onsi/1233018 to your computer and use it in GitHub Desktop.
OCMock argument matching compares classes incorrectly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import "SpecHelper.h" | |
| #import "OCMock.h" | |
| #define EXP_SHORTHAND | |
| #import "Expecta.h" | |
| @interface AFakeObject : NSObject | |
| - (void)callMe:(NSString *)name; | |
| @end | |
| @implementation AFakeObject | |
| - (void)callMe:(NSString *)name { | |
| } | |
| @end | |
| SPEC_BEGIN(StringSpecSpec) | |
| describe(@"StringSpec", ^{ | |
| __block NSString *constantString; | |
| __block NSString *nsString; | |
| beforeEach(^{ | |
| constantString = @"Joe"; //on iOS 4.3 this is an instance of NSString, on iOS 5.0 it is an instance of __NSCFConstantString | |
| nsString = [NSString stringWithFormat:@"%@", @"Joe"]; | |
| }); | |
| it(@"should pass on 5.0 and 4.3", ^{ | |
| AFakeObject *fake = [[[AFakeObject alloc] init] autorelease]; | |
| id mock = [OCMockObject partialMockForObject:fake]; | |
| [[mock expect] callMe:nsString]; | |
| [fake callMe:nsString]; | |
| [mock verify]; | |
| }); | |
| it(@"should fail on 5.0 but pass on 4.3", ^{ | |
| AFakeObject *fake = [[[AFakeObject alloc] init] autorelease]; | |
| id mock = [OCMockObject partialMockForObject:fake]; | |
| [[mock expect] callMe:constantString]; //on 5.0 OCMock will compare nsString and constantString using nsString.class == constantString.class and fail | |
| [fake callMe:nsString]; | |
| [mock verify]; | |
| }); | |
| }); | |
| SPEC_END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment