@@ -51,44 +51,46 @@ - (OCMInvocationStub *)stub
51
51
52
52
- (id )andReturn : (id )anObject
53
53
{
54
- [[self stub ] addInvocationAction: [[[OCMObjectReturnValueProvider alloc ] initWithValue: anObject] autorelease ]];
55
- return self;
54
+ Class returnValueProviderClass;
55
+ if (anObject == mockObject)
56
+ {
57
+ returnValueProviderClass = [OCMNonRetainingObjectReturnValueProvider class ];
58
+ } else
59
+ {
60
+ returnValueProviderClass = [OCMObjectReturnValueProvider class ];
61
+ }
62
+ [[self stub ] addInvocationAction: [[[returnValueProviderClass alloc ] initWithValue: anObject] autorelease ]];
63
+ return self;
56
64
}
57
65
58
66
- (id )andReturnValue : (NSValue *)aValue
59
67
{
60
68
[[self stub ] addInvocationAction: [[[OCMBoxedReturnValueProvider alloc ] initWithValue: aValue] autorelease ]];
61
- return self;
62
- }
63
-
64
- - (id )andReturnMockObject
65
- {
66
- [[self stub ] addInvocationAction: [[[OCMNonRetainingObjectReturnValueProvider alloc ] initWithValue: mockObject] autorelease ]];
67
- return self;
69
+ return self;
68
70
}
69
71
70
72
- (id )andThrow : (NSException *)anException
71
73
{
72
74
[[self stub ] addInvocationAction: [[[OCMExceptionReturnValueProvider alloc ] initWithValue: anException] autorelease ]];
73
- return self;
75
+ return self;
74
76
}
75
77
76
78
- (id )andPost : (NSNotification *)aNotification
77
79
{
78
80
[[self stub ] addInvocationAction: [[[OCMNotificationPoster alloc ] initWithNotification: aNotification] autorelease ]];
79
- return self;
81
+ return self;
80
82
}
81
83
82
84
- (id )andCall : (SEL )selector onObject : (id )anObject
83
85
{
84
86
[[self stub ] addInvocationAction: [[[OCMIndirectReturnValueProvider alloc ] initWithProvider: anObject andSelector: selector] autorelease ]];
85
- return self;
87
+ return self;
86
88
}
87
89
88
90
- (id )andDo : (void (^)(NSInvocation *))aBlock
89
91
{
90
92
[[self stub ] addInvocationAction: [[[OCMBlockCaller alloc ] initWithCallBlock: aBlock] autorelease ]];
91
- return self;
93
+ return self;
92
94
}
93
95
94
96
- (id )andForwardToRealObject
@@ -122,7 +124,7 @@ @implementation OCMStubRecorder (Properties)
122
124
{
123
125
id objValue = nil ;
124
126
[aValue getValue: &objValue];
125
- return (objValue == mockObject) ? [ self andReturnMockObject ] : [self andReturn: objValue];
127
+ return [self andReturn: objValue];
126
128
}
127
129
else
128
130
{
0 commit comments