Skip to content

Commit

Permalink
Merge pull request kiwi-bdd#230 from timle8n1/master
Browse files Browse the repository at this point in the history
Fix compile issues in pull request 223
  • Loading branch information
allending committed Mar 5, 2013
2 parents a87ee17 + be3b4b2 commit 050f3dc
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Classes/NSObject+KiwiStubAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,13 @@ - (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern withBlock:(id (^)
KWAssociateObjectStub(self, stub, YES);
}

+ (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue {
+ (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue
{
[self stubMessagePattern:aMessagePattern andReturn:aValue overrideExisting:YES];
}

+ (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue overrideExisting:(BOOL)override
{
if ([self methodSignatureForSelector:aMessagePattern.selector] == nil) {
[NSException raise:@"KWStubException" format:@"cannot stub -%@ because no such method exists",
NSStringFromSelector(aMessagePattern.selector)];
Expand All @@ -167,10 +173,14 @@ + (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aVa
Class interceptClass = KWSetupObjectInterceptSupport(self);
KWSetupMethodInterceptSupport(interceptClass, aMessagePattern.selector);
KWStub *stub = [KWStub stubWithMessagePattern:aMessagePattern value:aValue];
KWAssociateObjectStub(self, stub);
KWAssociateObjectStub(self, stub, override);
}

+ (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue times:(id)times afterThatReturn:(id)aSecondValue {
[self stubMessagePattern:aMessagePattern andReturn:aValue times:times afterThatReturn:aSecondValue overrideExisting:YES];
}

+ (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue times:(id)times afterThatReturn:(id)aSecondValue overrideExisting:(BOOL)override {
if ([self methodSignatureForSelector:aMessagePattern.selector] == nil) {
[NSException raise:@"KWStubException" format:@"cannot stub -%@ because no such method exists",
NSStringFromSelector(aMessagePattern.selector)];
Expand All @@ -179,10 +189,14 @@ + (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aVa
Class interceptClass = KWSetupObjectInterceptSupport(self);
KWSetupMethodInterceptSupport(interceptClass, aMessagePattern.selector);
KWStub *stub = [KWStub stubWithMessagePattern:aMessagePattern value:aValue times:times afterThatReturn:aSecondValue];
KWAssociateObjectStub(self, stub);
KWAssociateObjectStub(self, stub, override);
}

+ (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern withBlock:(id (^)(NSArray *params))block {
[self stubMessagePattern:aMessagePattern withBlock:block overrideExisting:YES];
}

+ (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern withBlock:(id (^)(NSArray *params))block overrideExisting:(BOOL)override {
if ([self methodSignatureForSelector:aMessagePattern.selector] == nil) {
[NSException raise:@"KWStubException" format:@"cannot stub -%@ because no such method exists",
NSStringFromSelector(aMessagePattern.selector)];
Expand All @@ -191,7 +205,7 @@ + (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern withBlock:(id (^)
Class interceptClass = KWSetupObjectInterceptSupport(self);
KWSetupMethodInterceptSupport(interceptClass, aMessagePattern.selector);
KWStub *stub = [KWStub stubWithMessagePattern:aMessagePattern block:block];
KWAssociateObjectStub(self, stub);
KWAssociateObjectStub(self, stub, override);
}

- (void)clearStubs {
Expand Down

0 comments on commit 050f3dc

Please sign in to comment.