File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -37,10 +37,18 @@ - (BOOL)isSatisfied
37
37
return isSatisfied;
38
38
}
39
39
40
- - (void )handleInvocation : ( NSInvocation *) anInvocation
40
+ - (void )addInvocationAction : ( id ) anAction
41
41
{
42
- [super handleInvocation: anInvocation];
42
+ if (matchAndReject)
43
+ {
44
+ [NSException raise: NSInternalInconsistencyException format: @" %@ : cannot add action to a reject stub; got %@ " ,
45
+ [self description ], anAction];
46
+ }
47
+ [super addInvocationAction: anAction];
48
+ }
43
49
50
+ - (void )handleInvocation : (NSInvocation *)anInvocation
51
+ {
44
52
if (matchAndReject)
45
53
{
46
54
isSatisfied = NO ;
@@ -49,8 +57,11 @@ - (void)handleInvocation:(NSInvocation *)anInvocation
49
57
}
50
58
else
51
59
{
60
+ [super handleInvocation: anInvocation];
52
61
isSatisfied = YES ;
53
62
}
54
63
}
55
64
65
+
66
+
56
67
@end
Original file line number Diff line number Diff line change @@ -291,6 +291,11 @@ - (void)testSetsUpReject
291
291
XCTAssertThrows ([mock verify ], @" Should have complained about rejected method being invoked" );
292
292
}
293
293
294
+ - (void )testThrowsWhenTryingToAddActionToReject
295
+ {
296
+ id mock = OCMClassMock ([TestClassForMacroTesting class ]);
297
+ XCTAssertThrows (OCMReject ([mock stringValue ]).andReturn (@" Foo" ));
298
+ }
294
299
295
300
- (void )testShouldNotReportErrorWhenMethodWasInvoked
296
301
{
Original file line number Diff line number Diff line change @@ -1082,6 +1082,12 @@ - (void)testThrowsWhenRejectedMethodIsCalledOnNiceMock
1082
1082
XCTAssertThrows ([mock uppercaseString ], @" Should have complained about rejected method being called." );
1083
1083
}
1084
1084
1085
+ - (void )testThrowsWhenTryingToAddActionToReject
1086
+ {
1087
+ mock = [OCMockObject niceMockForClass: [NSString class ]];
1088
+ XCTAssertThrows ([[[mock reject ] andReturn: @" Foo" ] stringValue ]);
1089
+ }
1090
+
1085
1091
- (void )testUncalledRejectStubDoesNotCountAsExpectation
1086
1092
{
1087
1093
mock = [OCMockObject niceMockForClass: [NSString class ]];
You can’t perform that action at this time.
0 commit comments