Latest1.5.0
Homepagehttps://github.com/rambler-digital-solutions/RamblerTyphoonUtils
LicenseMIT
Platformsios 7.0, requires ARC
Authors, , , ,

CocoaPods

Typhoon

Typhoon is a great tool, and iOS team in Rambler&Co loves it a lot. Besides actual contributing, we’ve developed some useful tools which cannot be included in the main project.

  1. RamblerInitialAssemblyCollector – this class can be used for activating assemblies on startup instead of plist integration.
  2. RamblerTyphoonAssemblyTests – A base test class used for TyphoonAssembly testing.

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

AssemblyCollector

At first, make your assemblies conform the RamblerInitialAssembly protocol:

@interface ApplicationAssembly : TyphoonAssembly <RamblerInitialAssembly>

@end

Then, instead of adding this assembly in the Info.plist file, add the following code in the AppDelegate:

@implementation AppDelegate

- (NSArray *)initialAssemblies {
    RamblerInitialAssemblyCollector *collector = [RamblerInitialAssemblyCollector new];
    return [collector collectInitialAssemblyClasses];
}

@end

The RamblerInitialAssemblyCollector will find your assembly in the runtime and automatically activate it.

AssemblyTesting

Inherit your test from the RamblerTyphoonAssemblyTests:

@interface RamblerApplicationAssemblyTests : RamblerTyphoonAssemblyTests

@property (nonatomic, strong) RamblerApplicationAssembly *assembly;

@end

Write new tests: one per your assembly method. To describe the type of a test object use RamblerTyphoonAssemblyTestsTypeDescriptor. Don’t forget that we don’t verify blocks and primitive types: just only classes and protocols.

- (void)testThatAssemblyCreatesAppDelegateWithDependencies {
    // given
    Class expectedClass = [RamblerAppDelegate class];
    NSArray *expectedProtocols = @[
                                   @protocol(UIApplicationDelegate),
                                   @protocol(RamblerFooProtocol)
                                   ];
    RamblerTyphoonAssemblyTestsTypeDescriptor *resultTypeDescriptor =
        [RamblerTyphoonAssemblyTestsTypeDescriptor descriptorWithClass:expectedClass
                                                          andProtocols:expectedProtocols];
    NSArray *dependencies = @[
                              RamblerSelector(injectedString),
                              RamblerSelector(injectedPropertyWithProtocols)
                              ];

    // when
    id result = [self.assembly appDelegate];

    // then
    [self verifyTargetDependency:result
                  withDescriptor:resultTypeDescriptor
                    dependencies:dependencies];
}

You are testing the following things:

  • The target object is created
  • The result is of the required class and conforms to the required protocols
  • The result has all of the listed dependencies
  • Dependencies are of the right classes and conform to the required protocols

Installation

RamblerTyphoonUtils is available through CocoaPods. To use the AssemblyCollector:

pod "RamblerTyphoonUtils/AssemblyCollector"

To use the AssemblyTesting:

target 'ProjectNameTargetTests', :exclusive => true do
    pod "RamblerTyphoonUtils/AssemblyTesting"
end 

Warning: do not include AssemblyTesting subspec in the main target!

License

RamblerTyphoonUtils is available under the MIT license. See the LICENSE file for more info.

Authors

Latest podspec

{
    "name": "RamblerTyphoonUtils",
    "version": "1.5.0",
    "summary": "A collection of Typhoon utils and tools used by Rambler&Co.",
    "description": "Typhoon is a great tool, and iOS team in Rambler&Co loves it a lot. Besides actual contributing, we've developed some useful tools which cannot be included in the main project.n1. RamblerInitialAssemblyCollector - this class can be used for activating assemblies on startup instead of plist integration.n2. RamblerTyphoonAssemblyTests - A base test class used for TyphoonAssembly testing.",
    "homepage": "https://github.com/rambler-digital-solutions/RamblerTyphoonUtils",
    "license": "MIT",
    "authors": {
        "Egor Tolstoy": "[email protected]",
        "Irina Dyagileva": "[email protected]",
        "Andrey Rezanov": "[email protected]",
        "Andrey Zarembo-Godzyatsky": "[email protected]ru",
        "Aleksandr Sychev": "[email protected]"
    },
    "source": {
        "git": "https://github.com/rambler-digital-solutions/RamblerTyphoonUtils.git",
        "tag": "1.5.0"
    },
    "social_media_url": "https://twitter.com/rambler_ios",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "Code/Production/**/*.{h,m}",
    "subspecs": [
        {
            "name": "AssemblyCollector",
            "source_files": [
                "Code/Production/AssemblyCollector.h",
                "Code/Production/AssemblyCollector/*.{h,m}"
            ]
        },
        {
            "name": "AssemblyTesting",
            "source_files": [
                "Code/Testing/AssemblyTesting.h",
                "Code/Testing/AssemblyTesting/*.{h,m}"
            ],
            "frameworks": "XCTest",
            "user_target_xcconfig": {
                "FRAMEWORK_SEARCH_PATHS": "$(PLATFORM_DIR)/Developer/Library/Frameworks"
            }
        }
    ]
}

Pin It on Pinterest

Share This