Permalink
Browse files

Added feature to explicitly disable a partial mock.

git-svn-id: http://svn.mulle-kybernetik.com/OCMock/trunk@74 12620d81-68e2-0310-ae40-e3f550779089
  • Loading branch information...
1 parent f669423 commit 1ff3ec498633b233e85c8368f926f5901d52832c @erikdoe erikdoe committed Feb 15, 2011
View
@@ -1,6 +1,11 @@
Chronological listing of changes. If a particular SVN revision has no entry, that
check-in did not involve any code or feature changes.
+2011-02-15 (r74)
+
+* Added feature to explicitly disable a partial mock
+
+
2011-01-28 (r71)
* Updated example to work with iOS 4.2.
@@ -164,7 +164,7 @@
03F1FE8A10353A5F00E4962C /* NSMethodSignature+OCMAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 03F1FE8710353A5F00E4962C /* NSMethodSignature+OCMAdditions.h */; };
03F1FE8B10353A5F00E4962C /* NSMethodSignature+OCMAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 03F1FE8810353A5F00E4962C /* NSMethodSignature+OCMAdditions.m */; };
8DC2EF510486A6940098B216 /* OCMock_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 32DBCF5E0370ADEE00C91783 /* OCMock_Prefix.pch */; };
- 9F35D3DC0D349E7E00C05E52 /* OCMock in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* OCMock */; };
+ 9F35D3DC0D349E7E00C05E52 /* OCMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* OCMock.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -258,7 +258,7 @@
03F1FE8810353A5F00E4962C /* NSMethodSignature+OCMAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMethodSignature+OCMAdditions.m"; sourceTree = "<group>"; };
32DBCF5E0370ADEE00C91783 /* OCMock_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMock_Prefix.pch; sourceTree = "<group>"; };
8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; explicitFileType = text.plist.xml; fileEncoding = 4; path = Info.plist; sourceTree = "<group>"; };
- 8DC2EF5B0486A6940098B216 /* OCMock */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.framework; path = OCMock; sourceTree = BUILT_PRODUCTS_DIR; };
+ 8DC2EF5B0486A6940098B216 /* OCMock.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OCMock.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -275,7 +275,7 @@
files = (
03BF2D4008F1C6BA00978C59 /* SenTestingKit.framework in Frameworks */,
03BF2D4108F1C6BC00978C59 /* Foundation.framework in Frameworks */,
- 9F35D3DC0D349E7E00C05E52 /* OCMock in Frameworks */,
+ 9F35D3DC0D349E7E00C05E52 /* OCMock.framework in Frameworks */,
032797870E09F40E006CA665 /* OCHamcrest.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -310,7 +310,7 @@
034768DFFF38A50411DB9C8B /* Products */ = {
isa = PBXGroup;
children = (
- 8DC2EF5B0486A6940098B216 /* OCMock */,
+ 8DC2EF5B0486A6940098B216 /* OCMock.framework */,
03BF2D3708F1C69500978C59 /* OCMockTests.octest */,
033C84AF11F585CB0009B9CD /* libOCMock.a */,
03DAC01F11FEB771007AF17B /* libOCMock.a */,
@@ -665,7 +665,7 @@
name = OCMock;
productInstallPath = "$(HOME)/Library/Frameworks";
productName = OCMock;
- productReference = 8DC2EF5B0486A6940098B216 /* OCMock */;
+ productReference = 8DC2EF5B0486A6940098B216 /* OCMock.framework */;
productType = "com.apple.product-type.framework";
};
/* End PBXNativeTarget section */
View
@@ -697,10 +697,21 @@ - (void)testStubsMethodOnRealObjectReference
{
TestClassThatCallsSelf *realObject = [[[TestClassThatCallsSelf alloc] init] autorelease];
mock = [OCMockObject partialMockForObject:realObject];
- [[[mock stub] andReturn:@"FooFoo"] method1];
- STAssertEqualObjects(@"FooFoo", [realObject method1], @"Should have stubbed method.");
+ [[[mock stub] andReturn:@"TestFoo"] method1];
+ STAssertEqualObjects(@"TestFoo", [realObject method1], @"Should have stubbed method.");
}
+- (void)testRestoresObjectWhenStopped
+{
+ TestClassThatCallsSelf *realObject = [[[TestClassThatCallsSelf alloc] init] autorelease];
+ mock = [OCMockObject partialMockForObject:realObject];
+ [[[mock stub] andReturn:@"TestFoo"] method2];
+ STAssertEqualObjects(@"TestFoo", [realObject method2], @"Should have stubbed method.");
+ [mock stop];
+ STAssertEqualObjects(@"Foo", [realObject method2], @"Should have 'unstubbed' method.");
+}
+
+
- (void)testCallsToSelfInRealObjectAreShadowedByPartialMock
{
TestClassThatCallsSelf *foo = [[[TestClassThatCallsSelf alloc] init] autorelease];
@@ -709,7 +720,6 @@ - (void)testCallsToSelfInRealObjectAreShadowedByPartialMock
STAssertEqualObjects(@"FooFoo", [mock method1], @"Should have called through to stubbed method.");
}
-
- (NSString *)differentMethodInDifferentClass
{
return @"swizzled!";
@@ -14,6 +14,8 @@
- (NSObject *)realObject;
+- (void)stop;
+
- (void)setupSubclassForObject:(id)anObject;
- (void)setupForwarderForSelector:(SEL)selector;
@@ -61,9 +61,8 @@ - (id)initWithObject:(NSObject *)anObject
- (void)dealloc
{
- object_setClass(realObject, [self mockedClass]);
- [realObject release];
- [[self class] forgetPartialMockForObject:realObject];
+ if(realObject != nil)
+ [self stop];
[super dealloc];
}
@@ -77,6 +76,13 @@ - (NSObject *)realObject
return realObject;
}
+- (void)stop
+{
+ object_setClass(realObject, [self mockedClass]);
+ [realObject release];
+ [[self class] forgetPartialMockForObject:realObject];
+ realObject = nil;
+}
#pragma mark Subclass management

0 comments on commit 1ff3ec4

Please sign in to comment.