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
3737 return isSatisfied;
3838}
3939
40- - (void )handleInvocation : ( NSInvocation *) anInvocation
40+ - (void )addInvocationAction : ( id ) anAction
4141{
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+ }
4349
50+ - (void )handleInvocation : (NSInvocation *)anInvocation
51+ {
4452 if (matchAndReject)
4553 {
4654 isSatisfied = NO ;
@@ -49,8 +57,11 @@ - (void)handleInvocation:(NSInvocation *)anInvocation
4957 }
5058 else
5159 {
60+ [super handleInvocation: anInvocation];
5261 isSatisfied = YES ;
5362 }
5463}
5564
65+
66+
5667@end
Original file line number Diff line number Diff line change @@ -291,6 +291,11 @@ - (void)testSetsUpReject
291291 XCTAssertThrows ([mock verify ], @" Should have complained about rejected method being invoked" );
292292}
293293
294+ - (void )testThrowsWhenTryingToAddActionToReject
295+ {
296+ id mock = OCMClassMock ([TestClassForMacroTesting class ]);
297+ XCTAssertThrows (OCMReject ([mock stringValue ]).andReturn (@" Foo" ));
298+ }
294299
295300- (void )testShouldNotReportErrorWhenMethodWasInvoked
296301{
Original file line number Diff line number Diff line change @@ -1082,6 +1082,12 @@ - (void)testThrowsWhenRejectedMethodIsCalledOnNiceMock
10821082 XCTAssertThrows ([mock uppercaseString ], @" Should have complained about rejected method being called." );
10831083}
10841084
1085+ - (void )testThrowsWhenTryingToAddActionToReject
1086+ {
1087+ mock = [OCMockObject niceMockForClass: [NSString class ]];
1088+ XCTAssertThrows ([[[mock reject ] andReturn: @" Foo" ] stringValue ]);
1089+ }
1090+
10851091- (void )testUncalledRejectStubDoesNotCountAsExpectation
10861092{
10871093 mock = [OCMockObject niceMockForClass: [NSString class ]];
You can’t perform that action at this time.
0 commit comments