Skip to content

Commit

Permalink
rename mock to stub.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper Blues committed Jan 28, 2014
1 parent 866e47d commit 592ed04
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#import <Foundation/Foundation.h>
#import "TyphoonComponentFactory.h"

@protocol TyphoonComponentPostProcessor;

@interface TyphoonComponentFactory (TyphoonDefinitionRegisterer)

- (TyphoonDefinition*)definitionForKey:(NSString*)key;
Expand All @@ -22,6 +24,6 @@

- (void)addDefinitionToRegistry:(TyphoonDefinition*)definition;

- (void)addComponentPostProcessor:(id<TyphoonComponentFactoryPostProcessor>)postProcessor;
- (void)addComponentPostProcessor:(id <TyphoonComponentPostProcessor>)postProcessor;

@end
4 changes: 2 additions & 2 deletions Source/Factory/TyphoonComponentFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
NSMutableDictionary* _objectGraphSharedInstances;

TyphoonCallStack* _stack;
NSMutableArray* _postProcessors;
NSMutableArray* _factoryPostProcessors;
NSMutableArray* _componentPostProcessors;
BOOL _isLoading;
}
Expand All @@ -50,7 +50,7 @@
/**
* The attached factory post processors.
*/
@property(nonatomic, strong, readonly) NSArray* postProcessors;
@property(nonatomic, strong, readonly) NSArray* factoryPostProcessors;

/**
* The attached component post processors.
Expand Down
11 changes: 6 additions & 5 deletions Source/Factory/TyphoonComponentFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#import "TyphoonOrdered.h"
#import "TyphoonCallStack.h"
#import "TyphoonParentReferenceHydratingPostProcessor.h"
#import "TyphoonComponentPostProcessor.h"

@interface TyphoonDefinition (TyphoonComponentFactory)

Expand Down Expand Up @@ -52,7 +53,7 @@ - (id)init
_singletons = [[NSMutableDictionary alloc] init];
_objectGraphSharedInstances = [[NSMutableDictionary alloc] init];
_stack = [TyphoonCallStack stack];
_postProcessors = [[NSMutableArray alloc] init];
_factoryPostProcessors = [[NSMutableArray alloc] init];
_componentPostProcessors = [[NSMutableArray alloc] init];
[self attachPostProcessor:[[TyphoonParentReferenceHydratingPostProcessor alloc] init]];
}
Expand Down Expand Up @@ -187,7 +188,7 @@ - (NSArray*)registry
- (void)attachPostProcessor:(id <TyphoonComponentFactoryPostProcessor>)postProcessor
{
LogTrace(@"Attaching post processor: %@", postProcessor);
[_postProcessors addObject:postProcessor];
[_factoryPostProcessors addObject:postProcessor];
if ([self isLoaded])
{
LogDebug(@"Definitions registered, refreshing all singletons.");
Expand Down Expand Up @@ -250,13 +251,13 @@ - (NSArray*)orderedArray:(NSMutableArray*)array

- (void)preparePostProcessors
{
_postProcessors = [[self orderedArray:_postProcessors] mutableCopy];
_factoryPostProcessors = [[self orderedArray:_factoryPostProcessors] mutableCopy];
_componentPostProcessors = [[self orderedArray:_componentPostProcessors] mutableCopy];
}

- (void)applyPostProcessors
{
[_postProcessors enumerateObjectsUsingBlock:^(id <TyphoonComponentFactoryPostProcessor> postProcessor, NSUInteger idx, BOOL* stop)
[_factoryPostProcessors enumerateObjectsUsingBlock:^(id <TyphoonComponentFactoryPostProcessor> postProcessor, NSUInteger idx, BOOL* stop)
{
[postProcessor postProcessComponentFactory:self];
}];
Expand Down Expand Up @@ -339,7 +340,7 @@ - (void)addDefinitionToRegistry:(TyphoonDefinition*)definition
[_registry addObject:definition];
}

- (void)addComponentPostProcessor:(id <TyphoonComponentFactoryPostProcessor>)postProcessor
- (void)addComponentPostProcessor:(id <TyphoonComponentPostProcessor>)postProcessor
{
[_componentPostProcessors addObject:postProcessor];
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Factory/Shared/TyphoonSharedComponentFactoryTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ - (void)test_resolves_property_values

- (void)test_post_processor_component_recognized
{
assertThatUnsignedLong([_infrastructureComponentsFactory.postProcessors count], equalToInt(2)); //Attached + internal processors
assertThatUnsignedLong([_infrastructureComponentsFactory.factoryPostProcessors count], equalToInt(2)); //Attached + internal processors
}

- (void)test_resolves_property_values_from_multiple_files
Expand Down
18 changes: 9 additions & 9 deletions Tests/Factory/TyphoonComponentFactoryTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#import "Champion.h"
#import "AutoWiringKnight.h"
#import "Harlot.h"
#import "TyphoonComponentFactoryPostProcessorMock.h"
#import "TyphoonComponentFactoryPostProcessorStubImpl.h"
#import "TyphoonComponentFactory+TyphoonDefinitionRegisterer.h"
#import "ClassWithConstructor.h"
#import "TyphoonComponentPostProcessorMock.h"
Expand Down Expand Up @@ -207,25 +207,25 @@ - (void)test_able_to_describe_itself

- (void)test_post_processor_registration
{
[_componentFactory register:[TyphoonDefinition withClass:[TyphoonComponentFactoryPostProcessorMock class]]];
[_componentFactory register:[TyphoonDefinition withClass:[TyphoonComponentFactoryPostProcessorStubImpl class]]];
assertThatUnsignedLong([[_componentFactory registry] count], equalToUnsignedLong(0));
assertThatUnsignedLong([[_componentFactory postProcessors] count], equalToUnsignedLong(2)); //Attached + internal processors
assertThatUnsignedLong([[_componentFactory factoryPostProcessors] count], equalToUnsignedLong(2)); //Attached + internal processors
}

- (void)test_post_processors_applied
{
[_componentFactory register:[TyphoonDefinition withClass:[TyphoonComponentFactoryPostProcessorMock class]]];
[_componentFactory register:[TyphoonDefinition withClass:[TyphoonComponentFactoryPostProcessorMock class]]];
[_componentFactory register:[TyphoonDefinition withClass:[TyphoonComponentFactoryPostProcessorStubImpl class]]];
[_componentFactory register:[TyphoonDefinition withClass:[TyphoonComponentFactoryPostProcessorStubImpl class]]];
[_componentFactory register:[TyphoonDefinition withClass:[Knight class]]];

[_componentFactory load];

assertThatUnsignedLong([[_componentFactory postProcessors] count], equalToUnsignedLong(3)); //Attached + internal processors
for (TyphoonComponentFactoryPostProcessorMock* mock in _componentFactory.postProcessors)
assertThatUnsignedLong([[_componentFactory factoryPostProcessors] count], equalToUnsignedLong(3)); //Attached + internal processors
for (TyphoonComponentFactoryPostProcessorStubImpl* stub in _componentFactory.factoryPostProcessors)
{
if ([mock isKindOfClass:[TyphoonComponentFactoryPostProcessorMock class]])
if ([stub isKindOfClass:[TyphoonComponentFactoryPostProcessorStubImpl class]])
{
assertThatBool(mock.postProcessingCalled, equalToBool(YES));
assertThatBool(stub.postProcessingCalled, equalToBool(YES));
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions Tests/Tests.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
BA79816E8927B83FA26ECCCA /* TyphoonComponentDefinition+InstanceBuilderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7989092E6BC5E4F610F8F6 /* TyphoonComponentDefinition+InstanceBuilderTests.m */; };
BA798175B8A2E87C7D115A65 /* TyphoonInitializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7983A8E4C42C6B2FFD5650 /* TyphoonInitializerTests.m */; };
BA79822F5A3DC7BD7FE32221 /* Fort.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7989868392C101E6091300 /* Fort.m */; };
BA798242BDA57F78B4F24EF7 /* TyphoonComponentFactoryPostProcessorMock.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7981CAD5CC6E3952B1E1EA /* TyphoonComponentFactoryPostProcessorMock.m */; };
BA798242BDA57F78B4F24EF7 /* TyphoonComponentFactoryPostProcessorStubImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7981CAD5CC6E3952B1E1EA /* TyphoonComponentFactoryPostProcessorStubImpl.m */; };
BA79824D0006B0F9E50A41D3 /* TyphoonStringUtilsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA79854F29FE8A327A82E8BC /* TyphoonStringUtilsTests.m */; };
BA798251276DE3B4DD659331 /* InfrastructureComponentsAssembly.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7986BA57412F546CC5BA2A /* InfrastructureComponentsAssembly.m */; };
BA7982D26573611B9AE7E201 /* TyphoonScopeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798AC097A3709A7224F859 /* TyphoonScopeTests.m */; };
Expand All @@ -288,7 +288,7 @@
BA7984F1AF21BBCCBA6A3E7A /* ExtendedSimpleAssembly.m in Sources */ = {isa = PBXBuildFile; fileRef = BA79864B10A68F6419ACDB53 /* ExtendedSimpleAssembly.m */; };
BA7985809F1D32FF27FB680E /* ExtendedSimpleAssembly.m in Sources */ = {isa = PBXBuildFile; fileRef = BA79864B10A68F6419ACDB53 /* ExtendedSimpleAssembly.m */; };
BA7985DADDFF93F3411829B7 /* TyphoonPatcherTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7981F193E4701C2604BA5B /* TyphoonPatcherTests.m */; };
BA798601A0620F70FEB22F49 /* TyphoonComponentFactoryPostProcessorMock.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7981CAD5CC6E3952B1E1EA /* TyphoonComponentFactoryPostProcessorMock.m */; };
BA798601A0620F70FEB22F49 /* TyphoonComponentFactoryPostProcessorStubImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7981CAD5CC6E3952B1E1EA /* TyphoonComponentFactoryPostProcessorStubImpl.m */; };
BA7986A20922D9945F6EFBE7 /* TyphoonViewControllerNibResolverTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798D4E3084C51B7ACB6DC9 /* TyphoonViewControllerNibResolverTests.m */; };
BA7986EC5B14688897834CB4 /* TyphoonScopeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798AC097A3709A7224F859 /* TyphoonScopeTests.m */; };
BA7986F83BAB4E7D084B2AAA /* TyphoonUIColorConverterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7988D3F261F1B68761BEF2 /* TyphoonUIColorConverterTests.m */; };
Expand All @@ -306,7 +306,7 @@
BA7989A50FF0EAEAE2D5DD64 /* CoverageFixer.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7981CF6D5E560D84727EF9 /* CoverageFixer.m */; };
BA7989B57AD5BE95AD3E616E /* MiddleAgesAssembly.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798A4C4466A90E5E9479DD /* MiddleAgesAssembly.m */; };
BA7989B9C62F95712CB63910 /* TyphoonTestUtilsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA798A7BDF4CF779DFEB0F2E /* TyphoonTestUtilsTests.m */; };
BA7989CD73040A430989B5C1 /* TyphoonComponentFactoryPostProcessorMock.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7981CAD5CC6E3952B1E1EA /* TyphoonComponentFactoryPostProcessorMock.m */; };
BA7989CD73040A430989B5C1 /* TyphoonComponentFactoryPostProcessorStubImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7981CAD5CC6E3952B1E1EA /* TyphoonComponentFactoryPostProcessorStubImpl.m */; };
BA7989DFDD90A18B1EBE1E0F /* TyphoonPatcherTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BA7981F193E4701C2604BA5B /* TyphoonPatcherTests.m */; };
BA798A5B8557DA9B5F914B66 /* CircularDependenciesAssembly.m in Sources */ = {isa = PBXBuildFile; fileRef = BA79849EB1F762E5A4FF1196 /* CircularDependenciesAssembly.m */; };
BA798ABC0D96B2D9DA692D31 /* ObjectGraphAssembly.m in Sources */ = {isa = PBXBuildFile; fileRef = BA79894B5FAFD229DB3682E0 /* ObjectGraphAssembly.m */; };
Expand Down Expand Up @@ -509,9 +509,9 @@
75AB5EE356B3D0CE72380C22 /* TyphoonTestMethodSwizzler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TyphoonTestMethodSwizzler.h; sourceTree = "<group>"; };
B90D396911F743468FF96BB5 /* libPods-iOS Tests (Cocoapods).a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-iOS Tests (Cocoapods).a"; sourceTree = BUILT_PRODUCTS_DIR; };
BA798051AA546A46898B738A /* ObjectGraphAssembly.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectGraphAssembly.h; sourceTree = "<group>"; };
BA79806AA2419FD529AB6734 /* TyphoonComponentFactoryPostProcessorMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TyphoonComponentFactoryPostProcessorMock.h; sourceTree = "<group>"; };
BA79806AA2419FD529AB6734 /* TyphoonComponentFactoryPostProcessorStubImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TyphoonComponentFactoryPostProcessorStubImpl.h; sourceTree = "<group>"; };
BA79811A6C84ACD72416C162 /* InfrastructureComponentsAssembly.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InfrastructureComponentsAssembly.h; sourceTree = "<group>"; };
BA7981CAD5CC6E3952B1E1EA /* TyphoonComponentFactoryPostProcessorMock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TyphoonComponentFactoryPostProcessorMock.m; sourceTree = "<group>"; };
BA7981CAD5CC6E3952B1E1EA /* TyphoonComponentFactoryPostProcessorStubImpl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TyphoonComponentFactoryPostProcessorStubImpl.m; sourceTree = "<group>"; };
BA7981CF6D5E560D84727EF9 /* CoverageFixer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CoverageFixer.m; sourceTree = "<group>"; };
BA7981F193E4701C2604BA5B /* TyphoonPatcherTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TyphoonPatcherTests.m; sourceTree = "<group>"; };
BA7982085C6FF002B6BC2865 /* QuestProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuestProvider.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -955,9 +955,9 @@
BA7980B9CF1B97E34782F0D5 /* Configuration */ = {
isa = PBXGroup;
children = (
BA79806AA2419FD529AB6734 /* TyphoonComponentFactoryPostProcessorMock.h */,
BA79806AA2419FD529AB6734 /* TyphoonComponentFactoryPostProcessorStubImpl.h */,
BA798A54120B072EC0025FCB /* PropertyConfigurer */,
BA7981CAD5CC6E3952B1E1EA /* TyphoonComponentFactoryPostProcessorMock.m */,
BA7981CAD5CC6E3952B1E1EA /* TyphoonComponentFactoryPostProcessorStubImpl.m */,
BA798F4F967D71E194CD6AF1 /* Resolver */,
BA798B8F5CE2C9292F9F740F /* TyphoonBundleResourceTests.m */,
CAE54FA0A9F61F49CBA68D23 /* TyphoonComponentPostProcessorMock.m */,
Expand Down Expand Up @@ -1421,7 +1421,7 @@
75AB5318F0AF9702FAB20ABC /* TyphoonBlockComponentFactory_CollectionTests.m in Sources */,
75AB5105A442B91C8829135E /* TyphoonBlockComponentFactory_OverridingTests.m in Sources */,
BA798EE809EEDC8B00D40EB1 /* TyphoonPropertyPlaceholderConfigurerTests.m in Sources */,
BA7989CD73040A430989B5C1 /* TyphoonComponentFactoryPostProcessorMock.m in Sources */,
BA7989CD73040A430989B5C1 /* TyphoonComponentFactoryPostProcessorStubImpl.m in Sources */,
BA79812E69A0DEA51D42442F /* TyphoonViewControllerNibResolverTests.m in Sources */,
BA7985DADDFF93F3411829B7 /* TyphoonPatcherTests.m in Sources */,
BA7981389DA42F04313E85EF /* TyphoonBundleResourceTests.m in Sources */,
Expand Down Expand Up @@ -1521,7 +1521,7 @@
75AB5A3942EC509956CBF433 /* TyphoonBlockComponentFactory_CollectionTests.m in Sources */,
75AB55868AA0C2CCB7E2DE79 /* TyphoonBlockComponentFactory_OverridingTests.m in Sources */,
BA798006208715F5ED14041C /* TyphoonPropertyPlaceholderConfigurerTests.m in Sources */,
BA798601A0620F70FEB22F49 /* TyphoonComponentFactoryPostProcessorMock.m in Sources */,
BA798601A0620F70FEB22F49 /* TyphoonComponentFactoryPostProcessorStubImpl.m in Sources */,
BA798E077CA7C28EB0EB2EF4 /* TyphoonPatcherTests.m in Sources */,
BA798908C8A296FD5FCD31A7 /* TyphoonBundleResourceTests.m in Sources */,
BA798C878348D43289781407 /* TyphoonComponentDefinition+InstanceBuilderTests.m in Sources */,
Expand Down Expand Up @@ -1619,7 +1619,7 @@
75AB5AA0EB02DD1521B8C11B /* TyphoonBlockComponentFactory_CollectionTests.m in Sources */,
75AB5EB7083BAC9194CBB82B /* TyphoonBlockComponentFactory_OverridingTests.m in Sources */,
BA79806D4E8268823073EF92 /* TyphoonPropertyPlaceholderConfigurerTests.m in Sources */,
BA798242BDA57F78B4F24EF7 /* TyphoonComponentFactoryPostProcessorMock.m in Sources */,
BA798242BDA57F78B4F24EF7 /* TyphoonComponentFactoryPostProcessorStubImpl.m in Sources */,
BA7986A20922D9945F6EFBE7 /* TyphoonViewControllerNibResolverTests.m in Sources */,
BA7989DFDD90A18B1EBE1E0F /* TyphoonPatcherTests.m in Sources */,
BA7987F78E61D362F5BA8F8E /* TyphoonBundleResourceTests.m in Sources */,
Expand Down

0 comments on commit 592ed04

Please sign in to comment.