├── .gitignore ├── .travis.yml ├── Example ├── FMDBHelper.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── FMDBHelper-Example.xcscheme ├── FMDBHelper.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Podfile ├── Podfile.lock ├── Pods │ ├── FMDB │ │ ├── LICENSE.txt │ │ ├── README.markdown │ │ └── src │ │ │ └── fmdb │ │ │ ├── FMDB.h │ │ │ ├── FMDatabase.h │ │ │ ├── FMDatabase.m │ │ │ ├── FMDatabaseAdditions.h │ │ │ ├── FMDatabaseAdditions.m │ │ │ ├── FMDatabasePool.h │ │ │ ├── FMDatabasePool.m │ │ │ ├── FMDatabaseQueue.h │ │ │ ├── FMDatabaseQueue.m │ │ │ ├── FMResultSet.h │ │ │ └── FMResultSet.m │ ├── Kiwi │ │ ├── Classes │ │ │ ├── Config │ │ │ │ ├── KWAllTestsSuite.m │ │ │ │ ├── KWSuiteConfigurationBase.h │ │ │ │ └── KWSuiteConfigurationBase.m │ │ │ ├── Core │ │ │ │ ├── KWAny.h │ │ │ │ ├── KWAny.m │ │ │ │ ├── KWBackgroundTask.h │ │ │ │ ├── KWBackgroundTask.m │ │ │ │ ├── KWBlock.h │ │ │ │ ├── KWBlock.m │ │ │ │ ├── KWCallSite.h │ │ │ │ ├── KWCallSite.m │ │ │ │ ├── KWCaptureSpy.h │ │ │ │ ├── KWCaptureSpy.m │ │ │ │ ├── KWCountType.h │ │ │ │ ├── KWDeviceInfo.h │ │ │ │ ├── KWDeviceInfo.m │ │ │ │ ├── KWExample.h │ │ │ │ ├── KWExample.m │ │ │ │ ├── KWExampleDelegate.h │ │ │ │ ├── KWExampleNodeVisitor.h │ │ │ │ ├── KWExampleSuite.h │ │ │ │ ├── KWExampleSuite.m │ │ │ │ ├── KWExampleSuiteBuilder.h │ │ │ │ ├── KWExampleSuiteBuilder.m │ │ │ │ ├── KWExpectationType.h │ │ │ │ ├── KWFailure.h │ │ │ │ ├── KWFailure.m │ │ │ │ ├── KWFormatter.h │ │ │ │ ├── KWFormatter.m │ │ │ │ ├── KWFutureObject.h │ │ │ │ ├── KWFutureObject.m │ │ │ │ ├── KWInvocationCapturer.h │ │ │ │ ├── KWInvocationCapturer.m │ │ │ │ ├── KWLet.h │ │ │ │ ├── KWMatcher.h │ │ │ │ ├── KWMatcher.m │ │ │ │ ├── KWMatcherFactory.h │ │ │ │ ├── KWMatcherFactory.m │ │ │ │ ├── KWMatchers.h │ │ │ │ ├── KWMatchers.m │ │ │ │ ├── KWMatching.h │ │ │ │ ├── KWMessagePattern.h │ │ │ │ ├── KWMessagePattern.m │ │ │ │ ├── KWMessageSpying.h │ │ │ │ ├── KWMessageTracker.h │ │ │ │ ├── KWMessageTracker.m │ │ │ │ ├── KWNull.h │ │ │ │ ├── KWNull.m │ │ │ │ ├── KWObjCUtilities.h │ │ │ │ ├── KWObjCUtilities.m │ │ │ │ ├── KWProbe.h │ │ │ │ ├── KWProbePoller.h │ │ │ │ ├── KWProbePoller.m │ │ │ │ ├── KWReporting.h │ │ │ │ ├── KWSpec.h │ │ │ │ ├── KWSpec.m │ │ │ │ ├── KWStringUtilities.h │ │ │ │ ├── KWStringUtilities.m │ │ │ │ ├── KWSymbolicator.h │ │ │ │ ├── KWSymbolicator.m │ │ │ │ ├── KWValue.h │ │ │ │ ├── KWValue.m │ │ │ │ ├── KWWorkarounds.h │ │ │ │ ├── KWWorkarounds.m │ │ │ │ ├── Kiwi.h │ │ │ │ ├── KiwiBlockMacros.h │ │ │ │ ├── KiwiConfiguration.h │ │ │ │ ├── KiwiMacros.h │ │ │ │ ├── NSInvocation+KiwiAdditions.h │ │ │ │ ├── NSInvocation+KiwiAdditions.m │ │ │ │ ├── NSInvocation+OCMAdditions.h │ │ │ │ ├── NSInvocation+OCMAdditions.m │ │ │ │ ├── NSMethodSignature+KiwiAdditions.h │ │ │ │ ├── NSMethodSignature+KiwiAdditions.m │ │ │ │ ├── NSNumber+KiwiAdditions.h │ │ │ │ ├── NSNumber+KiwiAdditions.m │ │ │ │ ├── NSObject+KiwiSpyAdditions.h │ │ │ │ ├── NSObject+KiwiSpyAdditions.m │ │ │ │ ├── NSObject+KiwiVerifierAdditions.h │ │ │ │ ├── NSObject+KiwiVerifierAdditions.m │ │ │ │ ├── NSProxy+KiwiVerifierAdditions.h │ │ │ │ ├── NSProxy+KiwiVerifierAdditions.m │ │ │ │ ├── NSValue+KiwiAdditions.h │ │ │ │ └── NSValue+KiwiAdditions.m │ │ │ ├── Matchers │ │ │ │ ├── KWBeBetweenMatcher.h │ │ │ │ ├── KWBeBetweenMatcher.m │ │ │ │ ├── KWBeEmptyMatcher.h │ │ │ │ ├── KWBeEmptyMatcher.m │ │ │ │ ├── KWBeIdenticalToMatcher.h │ │ │ │ ├── KWBeIdenticalToMatcher.m │ │ │ │ ├── KWBeKindOfClassMatcher.h │ │ │ │ ├── KWBeKindOfClassMatcher.m │ │ │ │ ├── KWBeMemberOfClassMatcher.h │ │ │ │ ├── KWBeMemberOfClassMatcher.m │ │ │ │ ├── KWBeSubclassOfClassMatcher.h │ │ │ │ ├── KWBeSubclassOfClassMatcher.m │ │ │ │ ├── KWBeTrueMatcher.h │ │ │ │ ├── KWBeTrueMatcher.m │ │ │ │ ├── KWBeWithinMatcher.h │ │ │ │ ├── KWBeWithinMatcher.m │ │ │ │ ├── KWBeZeroMatcher.h │ │ │ │ ├── KWBeZeroMatcher.m │ │ │ │ ├── KWBlockRaiseMatcher.h │ │ │ │ ├── KWBlockRaiseMatcher.m │ │ │ │ ├── KWChangeMatcher.h │ │ │ │ ├── KWChangeMatcher.m │ │ │ │ ├── KWConformToProtocolMatcher.h │ │ │ │ ├── KWConformToProtocolMatcher.m │ │ │ │ ├── KWContainMatcher.h │ │ │ │ ├── KWContainMatcher.m │ │ │ │ ├── KWContainStringMatcher.h │ │ │ │ ├── KWContainStringMatcher.m │ │ │ │ ├── KWEqualMatcher.h │ │ │ │ ├── KWEqualMatcher.m │ │ │ │ ├── KWGenericMatchEvaluator.h │ │ │ │ ├── KWGenericMatchEvaluator.m │ │ │ │ ├── KWGenericMatcher.h │ │ │ │ ├── KWGenericMatcher.m │ │ │ │ ├── KWGenericMatchingAdditions.h │ │ │ │ ├── KWGenericMatchingAdditions.m │ │ │ │ ├── KWHaveMatcher.h │ │ │ │ ├── KWHaveMatcher.m │ │ │ │ ├── KWHaveValueMatcher.h │ │ │ │ ├── KWHaveValueMatcher.m │ │ │ │ ├── KWInequalityMatcher.h │ │ │ │ ├── KWInequalityMatcher.m │ │ │ │ ├── KWNilMatcher.h │ │ │ │ ├── KWNilMatcher.m │ │ │ │ ├── KWNotificationMatcher.h │ │ │ │ ├── KWNotificationMatcher.m │ │ │ │ ├── KWReceiveMatcher.h │ │ │ │ ├── KWReceiveMatcher.m │ │ │ │ ├── KWRegularExpressionPatternMatcher.h │ │ │ │ ├── KWRegularExpressionPatternMatcher.m │ │ │ │ ├── KWRespondToSelectorMatcher.h │ │ │ │ ├── KWRespondToSelectorMatcher.m │ │ │ │ ├── KWStringContainsMatcher.h │ │ │ │ ├── KWStringContainsMatcher.m │ │ │ │ ├── KWStringPrefixMatcher.h │ │ │ │ ├── KWStringPrefixMatcher.m │ │ │ │ ├── KWUserDefinedMatcher.h │ │ │ │ └── KWUserDefinedMatcher.m │ │ │ ├── Mocking │ │ │ │ ├── KWMock.h │ │ │ │ ├── KWMock.m │ │ │ │ ├── NSObject+KiwiMockAdditions.h │ │ │ │ └── NSObject+KiwiMockAdditions.m │ │ │ ├── Nodes │ │ │ │ ├── KWAfterAllNode.h │ │ │ │ ├── KWAfterAllNode.m │ │ │ │ ├── KWAfterEachNode.h │ │ │ │ ├── KWAfterEachNode.m │ │ │ │ ├── KWBeforeAllNode.h │ │ │ │ ├── KWBeforeAllNode.m │ │ │ │ ├── KWBeforeEachNode.h │ │ │ │ ├── KWBeforeEachNode.m │ │ │ │ ├── KWBlockNode.h │ │ │ │ ├── KWBlockNode.m │ │ │ │ ├── KWContextNode.h │ │ │ │ ├── KWContextNode.m │ │ │ │ ├── KWExampleNode.h │ │ │ │ ├── KWItNode.h │ │ │ │ ├── KWItNode.m │ │ │ │ ├── KWLetNode.h │ │ │ │ ├── KWLetNode.m │ │ │ │ ├── KWPendingNode.h │ │ │ │ ├── KWPendingNode.m │ │ │ │ ├── KWRegisterMatchersNode.h │ │ │ │ └── KWRegisterMatchersNode.m │ │ │ ├── Shared Examples │ │ │ │ ├── KWSharedExample.h │ │ │ │ ├── KWSharedExample.m │ │ │ │ ├── KWSharedExampleRegistry.h │ │ │ │ └── KWSharedExampleRegistry.m │ │ │ ├── Stubbing │ │ │ │ ├── KWIntercept.h │ │ │ │ ├── KWIntercept.m │ │ │ │ ├── KWStub.h │ │ │ │ ├── KWStub.m │ │ │ │ ├── NSObject+KiwiStubAdditions.h │ │ │ │ └── NSObject+KiwiStubAdditions.m │ │ │ └── Verifiers │ │ │ │ ├── KWAsyncVerifier.h │ │ │ │ ├── KWAsyncVerifier.m │ │ │ │ ├── KWExistVerifier.h │ │ │ │ ├── KWExistVerifier.m │ │ │ │ ├── KWMatchVerifier.h │ │ │ │ ├── KWMatchVerifier.m │ │ │ │ └── KWVerifying.h │ │ ├── License.txt │ │ └── Readme.md │ ├── Local Podspecs │ │ └── FMDBHelper.podspec.json │ ├── Manifest.lock │ ├── Pods.xcodeproj │ │ └── project.pbxproj │ └── Target Support Files │ │ ├── FMDB │ │ ├── FMDB-dummy.m │ │ ├── FMDB-prefix.pch │ │ └── FMDB.xcconfig │ │ ├── FMDBHelper │ │ ├── FMDBHelper-dummy.m │ │ ├── FMDBHelper-prefix.pch │ │ └── FMDBHelper.xcconfig │ │ ├── Kiwi │ │ ├── Kiwi-dummy.m │ │ ├── Kiwi-prefix.pch │ │ └── Kiwi.xcconfig │ │ └── Pods-FMDBHelper_Tests │ │ ├── Pods-FMDBHelper_Tests-acknowledgements.markdown │ │ ├── Pods-FMDBHelper_Tests-acknowledgements.plist │ │ ├── Pods-FMDBHelper_Tests-dummy.m │ │ ├── Pods-FMDBHelper_Tests-frameworks.sh │ │ ├── Pods-FMDBHelper_Tests-resources.sh │ │ ├── Pods-FMDBHelper_Tests.debug.xcconfig │ │ └── Pods-FMDBHelper_Tests.release.xcconfig └── Tests │ ├── Dept.h │ ├── Dept.m │ ├── Dog.h │ ├── Dog.m │ ├── Tests-Info.plist │ ├── Tests-Prefix.pch │ ├── Tests.m │ ├── User.h │ ├── User.m │ ├── demo.json │ └── en.lproj │ └── InfoPlist.strings ├── FMDBHelper.podspec ├── FMDBHelper ├── Assets │ └── .gitkeep └── Classes │ ├── FMDBHelper.h │ ├── FMDBHelper.m │ ├── NSObject+JCAdditionsORM.h │ └── NSObject+JCAdditionsORM.m ├── LICENSE ├── README.md ├── _Pods.xcodeproj ├── logo.png └── performance.png /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | 22 | # Bundler 23 | .bundle 24 | 25 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 26 | # Carthage/Checkouts 27 | 28 | Carthage/Build 29 | 30 | # We recommend against adding the Pods directory to your .gitignore. However 31 | # you should judge for yourself, the pros and cons are mentioned at: 32 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 33 | # 34 | # Note: if you ignore the Pods directory, make sure to uncomment 35 | # `pod install` in .travis.yml 36 | # 37 | Pods/ 38 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * https://www.objc.io/issues/6-build-tools/travis-ci/ 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | osx_image: xcode7.3 6 | language: objective-c 7 | # cache: cocoapods 8 | # podfile: Example/Podfile 9 | # before_install: 10 | # - gem install cocoapods # Since Travis is not always on latest version 11 | # - pod install --project-directory=Example 12 | script: 13 | - set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/FMDBHelper.xcworkspace -scheme FMDBHelper-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty 14 | - pod lib lint 15 | -------------------------------------------------------------------------------- /Example/FMDBHelper.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/FMDBHelper.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/FMDBHelper.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | 3 | platform :ios, '9.0' 4 | 5 | inhibit_all_warnings! 6 | 7 | target 'FMDBHelper_Tests' do 8 | pod 'FMDBHelper', :path => '../' 9 | 10 | pod 'Kiwi', '3.0.0' 11 | end 12 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - FMDB (2.7.5): 3 | - FMDB/standard (= 2.7.5) 4 | - FMDB/standard (2.7.5) 5 | - FMDBHelper (1.1.0): 6 | - FMDB (= 2.7.5) 7 | - Kiwi (3.0.0) 8 | 9 | DEPENDENCIES: 10 | - FMDBHelper (from `../`) 11 | - Kiwi (= 3.0.0) 12 | 13 | SPEC REPOS: 14 | https://github.com/cocoapods/specs.git: 15 | - FMDB 16 | - Kiwi 17 | 18 | EXTERNAL SOURCES: 19 | FMDBHelper: 20 | :path: "../" 21 | 22 | SPEC CHECKSUMS: 23 | FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a 24 | FMDBHelper: 6fb8cf752838b308876ef989603e48442ecd4c37 25 | Kiwi: fbeafef0f00e4d8f7dcb3420a4930afe70af77f7 26 | 27 | PODFILE CHECKSUM: 6f6a1127fb3749b24238e061a948978f12a6e8c3 28 | 29 | COCOAPODS: 1.5.3 30 | -------------------------------------------------------------------------------- /Example/Pods/FMDB/LICENSE.txt: -------------------------------------------------------------------------------- 1 | If you are using FMDB in your project, I'd love to hear about it. Let Gus know 2 | by sending an email to gus@flyingmeat.com. 3 | 4 | And if you happen to come across either Gus Mueller or Rob Ryan in a bar, you 5 | might consider purchasing a drink of their choosing if FMDB has been useful to 6 | you. 7 | 8 | Finally, and shortly, this is the MIT License. 9 | 10 | Copyright (c) 2008-2014 Flying Meat Inc. 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy 13 | of this software and associated documentation files (the "Software"), to deal 14 | in the Software without restriction, including without limitation the rights 15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | copies of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be included in 20 | all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | THE SOFTWARE. -------------------------------------------------------------------------------- /Example/Pods/FMDB/src/fmdb/FMDB.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | FOUNDATION_EXPORT double FMDBVersionNumber; 4 | FOUNDATION_EXPORT const unsigned char FMDBVersionString[]; 5 | 6 | #import "FMDatabase.h" 7 | #import "FMResultSet.h" 8 | #import "FMDatabaseAdditions.h" 9 | #import "FMDatabaseQueue.h" 10 | #import "FMDatabasePool.h" 11 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Config/KWAllTestsSuite.m: -------------------------------------------------------------------------------- 1 | // 2 | // XCTestSuite+KWConfiguration.m 3 | // Kiwi 4 | // 5 | // Created by Adam Sharp on 1/07/2014. 6 | // Copyright (c) 2014 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "KWSuiteConfigurationBase.h" 12 | 13 | @interface _KWAllTestsSuite : XCTestSuite 14 | @end 15 | 16 | @implementation _KWAllTestsSuite 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | [[KWSuiteConfigurationBase defaultConfiguration] setUp]; 21 | } 22 | 23 | - (void)tearDown { 24 | [[KWSuiteConfigurationBase defaultConfiguration] tearDown]; 25 | [super tearDown]; 26 | } 27 | 28 | @end 29 | 30 | @interface XCTestSuite (KWConfiguration) 31 | @end 32 | 33 | @implementation XCTestSuite (KWConfiguration) 34 | 35 | + (void)load { 36 | static dispatch_once_t onceToken; 37 | dispatch_once(&onceToken, ^{ 38 | Method testSuiteWithName = class_getClassMethod(self, @selector(testSuiteWithName:)); 39 | Method kiwi_testSuiteWithName = class_getClassMethod(self, @selector(kiwi_testSuiteWithName:)); 40 | method_exchangeImplementations(testSuiteWithName, kiwi_testSuiteWithName); 41 | }); 42 | } 43 | 44 | + (id)kiwi_testSuiteWithName:(NSString *)aName { 45 | id suite = [self kiwi_testSuiteWithName:aName]; 46 | if ([aName isEqualToString:@"All tests"] || [aName hasSuffix:@".xctest"]) { 47 | if ([suite isMemberOfClass:[XCTestSuite class]]) { 48 | object_setClass(suite, [_KWAllTestsSuite class]); 49 | } 50 | } 51 | return suite; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Config/KWSuiteConfigurationBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWSuiteConfigurationBase.h 3 | // Kiwi 4 | // 5 | // Created by Adam Sharp on 14/12/2013. 6 | // Copyright (c) 2013 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface KWSuiteConfigurationBase : NSObject 12 | 13 | + (instancetype)defaultConfiguration; 14 | 15 | - (void)configureSuite; 16 | 17 | - (void)setUp; 18 | - (void)tearDown; 19 | 20 | @property (nonatomic, copy) void (^beforeAllSpecsBlock)(void); 21 | @property (nonatomic, copy) void (^afterAllSpecsBlock)(void); 22 | 23 | @end 24 | 25 | void beforeAllSpecs(void (^block)(void)); 26 | void afterAllSpecs(void (^block)(void)); 27 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Config/KWSuiteConfigurationBase.m: -------------------------------------------------------------------------------- 1 | // 2 | // KWSuiteConfigurationBase.m 3 | // Kiwi 4 | // 5 | // Created by Adam Sharp on 14/12/2013. 6 | // Copyright (c) 2013 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import "KWSuiteConfigurationBase.h" 10 | #import "KWSpec.h" 11 | 12 | #define INVOKE(block) if((block)) { (block)(); } 13 | 14 | void beforeEachSpec(void (^block)(void)); 15 | void afterEachSpec(void (^block)(void)); 16 | 17 | @interface KWSuiteConfigurationBase () 18 | @property (nonatomic, copy) void (^beforeEachSpecBlock)(void); 19 | @property (nonatomic, copy) void (^afterEachSpecBlock)(void); 20 | @end 21 | 22 | @implementation KWSuiteConfigurationBase 23 | 24 | + (instancetype)defaultConfiguration 25 | { 26 | static Class configClass; 27 | static KWSuiteConfigurationBase *defaultConfiguration; 28 | 29 | static dispatch_once_t onceToken; 30 | dispatch_once(&onceToken, ^{ 31 | configClass = NSClassFromString(@"KWSuiteConfiguration"); 32 | if (configClass && [configClass isSubclassOfClass:[self class]]) { 33 | defaultConfiguration = [configClass new]; 34 | } 35 | }); 36 | 37 | return defaultConfiguration; 38 | } 39 | 40 | - (void)configureSuite {} 41 | 42 | - (void)setUp { 43 | [self configureSuite]; 44 | INVOKE(self.beforeAllSpecsBlock); 45 | } 46 | 47 | - (void)tearDown { 48 | INVOKE(self.afterAllSpecsBlock); 49 | } 50 | 51 | #pragma mark - Unused methods 52 | 53 | - (void)setUpSpec:(KWSpec *)spec { 54 | INVOKE(self.beforeEachSpecBlock); 55 | } 56 | 57 | - (void)tearDownSpec:(KWSpec *)spec { 58 | INVOKE(self.afterEachSpecBlock); 59 | } 60 | 61 | @end 62 | 63 | void beforeAllSpecs(void (^block)(void)) { 64 | [[KWSuiteConfigurationBase defaultConfiguration] setBeforeAllSpecsBlock:block]; 65 | } 66 | 67 | void afterAllSpecs(void (^block)(void)) { 68 | [[KWSuiteConfigurationBase defaultConfiguration] setAfterAllSpecsBlock:block]; 69 | } 70 | 71 | void beforeEachSpec(void (^block)(void)) { 72 | [[KWSuiteConfigurationBase defaultConfiguration] setBeforeEachSpecBlock:block]; 73 | } 74 | 75 | void afterEachSpec(void (^block)(void)) { 76 | [[KWSuiteConfigurationBase defaultConfiguration] setAfterEachSpecBlock:block]; 77 | } 78 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWAny.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | // KWAny exists to determine arguments in a message pattern that should 10 | // match any value. Used for pointers as well as for scalar values. 11 | @interface KWAny : NSObject 12 | 13 | #pragma mark - Initializing 14 | 15 | + (id)any; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWAny.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWAny.h" 8 | 9 | @implementation KWAny 10 | 11 | #pragma mark - Initializing 12 | 13 | + (id)any { 14 | static KWAny *sharedAny = nil; 15 | static dispatch_once_t onceToken; 16 | dispatch_once(&onceToken, ^{ 17 | sharedAny = [self new]; 18 | 19 | }); 20 | return sharedAny; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWBackgroundTask.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | // Used to suppress compiler warnings by 10 | // casting receivers to this protocol 11 | @protocol NSTask_KWWarningSuppressor 12 | 13 | - (void)setLaunchPath:(NSString *)path; 14 | - (void)setArguments:(NSArray *)arguments; 15 | - (void)setEnvironment:(NSDictionary *)dict; 16 | - (void)setStandardOutput:(id)output; 17 | - (void)setStandardError:(id)output; 18 | - (void)launch; 19 | - (void)waitUntilExit; 20 | 21 | @property (readonly) int terminationStatus; 22 | 23 | @end 24 | 25 | @interface KWBackgroundTask : NSObject 26 | 27 | @property (nonatomic, readonly) id task; 28 | @property (nonatomic, readonly) NSPipe *standardOutput; 29 | @property (nonatomic, readonly) NSPipe *standardError; 30 | @property (nonatomic, readonly) NSString *command; 31 | @property (nonatomic, readonly) NSArray *arguments; 32 | @property (nonatomic, readonly) NSData *output; 33 | 34 | - (instancetype)initWithCommand:(NSString *)command arguments:(NSArray *)arguments; 35 | 36 | - (void)launchAndWaitForExit; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWBlock.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @interface KWBlock : NSObject 10 | 11 | #pragma mark - Initializing 12 | - (id)initWithBlock:(void (^)(void))block; 13 | 14 | + (id)blockWithBlock:(void (^)(void))block; 15 | 16 | #pragma mark - Calling Blocks 17 | 18 | - (void)call; 19 | 20 | @end 21 | 22 | #pragma mark - Creating Blocks 23 | 24 | KWBlock *theBlock(void (^block)(void)); 25 | KWBlock *lambda(void (^block)(void)); 26 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWBlock.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWBlock.h" 8 | 9 | @interface KWBlock() 10 | 11 | #pragma mark - Properties 12 | 13 | @property (nonatomic, readonly, copy) void (^block)(void); 14 | 15 | @end 16 | 17 | @implementation KWBlock 18 | 19 | #pragma mark - Initializing 20 | 21 | - (id)initWithBlock:(void (^)(void))block { 22 | self = [super init]; 23 | if (self) { 24 | _block = [block copy]; 25 | } 26 | 27 | return self; 28 | } 29 | 30 | + (id)blockWithBlock:(void (^)(void))aBlock { 31 | return [[self alloc] initWithBlock:aBlock]; 32 | } 33 | 34 | #pragma mark - Calling Blocks 35 | 36 | - (void)call { 37 | self.block(); 38 | } 39 | 40 | @end 41 | 42 | #pragma mark - Creating Blocks 43 | 44 | KWBlock *theBlock(void (^block)(void)) { 45 | return lambda(block); 46 | } 47 | 48 | KWBlock *lambda(void (^block)(void)) { 49 | return [KWBlock blockWithBlock:block]; 50 | } 51 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWCallSite.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @interface KWCallSite : NSObject 10 | 11 | #pragma mark - Initializing 12 | 13 | - (id)initWithFilename:(NSString *)aFilename lineNumber:(NSUInteger)aLineNumber; 14 | 15 | + (id)callSiteWithFilename:(NSString *)aFilename lineNumber:(NSUInteger)aLineNumber; 16 | 17 | #pragma mark - Properties 18 | 19 | @property (nonatomic, readonly, copy) NSString *filename; 20 | @property (nonatomic, readonly) NSUInteger lineNumber; 21 | 22 | #pragma mark - Identifying and Comparing 23 | 24 | - (BOOL)isEqualToCallSite:(KWCallSite *)aCallSite; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWCallSite.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWCallSite.h" 8 | 9 | @implementation KWCallSite 10 | 11 | #pragma mark - Initializing 12 | 13 | - (id)initWithFilename:(NSString *)aFilename lineNumber:(NSUInteger)aLineNumber { 14 | self = [super init]; 15 | if (self) { 16 | _filename = [aFilename copy]; 17 | _lineNumber = aLineNumber; 18 | } 19 | 20 | return self; 21 | } 22 | 23 | + (id)callSiteWithFilename:(NSString *)aFilename lineNumber:(NSUInteger)aLineNumber { 24 | return [[self alloc] initWithFilename:aFilename lineNumber:aLineNumber]; 25 | } 26 | 27 | #pragma mark - Identifying and Comparing 28 | 29 | - (NSUInteger)hash { 30 | return [[NSString stringWithFormat:@"%@%u", self.filename, (unsigned)self.lineNumber] hash]; 31 | } 32 | 33 | - (BOOL)isEqual:(id)anObject { 34 | if (![anObject isKindOfClass:[KWCallSite class]]) 35 | return NO; 36 | 37 | return [self isEqualToCallSite:anObject]; 38 | } 39 | 40 | - (BOOL)isEqualToCallSite:(KWCallSite *)aCallSite { 41 | return [self.filename isEqualToString:aCallSite.filename] && (self.lineNumber == aCallSite.lineNumber); 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWCaptureSpy.h: -------------------------------------------------------------------------------- 1 | #import "KWMessageSpying.h" 2 | 3 | @interface KWCaptureSpy : NSObject 4 | 5 | @property (nonatomic, strong, readonly) id argument; 6 | 7 | - (id)initWithArgumentIndex:(NSUInteger)index; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWCaptureSpy.m: -------------------------------------------------------------------------------- 1 | #import "KWCaptureSpy.h" 2 | 3 | #import "KWObjCUtilities.h" 4 | #import "KWNull.h" 5 | #import "KWValue.h" 6 | #import "NSInvocation+KiwiAdditions.h" 7 | #import "NSMethodSignature+KiwiAdditions.h" 8 | 9 | @interface KWCaptureSpy() 10 | 11 | @property (nonatomic, strong) id argument; 12 | 13 | @end 14 | 15 | @implementation KWCaptureSpy { 16 | NSUInteger _argumentIndex; 17 | } 18 | 19 | - (id)initWithArgumentIndex:(NSUInteger)index { 20 | self = [super init]; 21 | if (self) { 22 | _argumentIndex = index; 23 | } 24 | return self; 25 | } 26 | 27 | - (id)argument { 28 | if (!_argument) { 29 | @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Argument requested has yet to be captured." userInfo:nil]; 30 | } 31 | 32 | if(_argument == [KWNull null]) { 33 | return nil; 34 | } 35 | else { 36 | return _argument; 37 | } 38 | } 39 | 40 | - (void)object:(id)anObject didReceiveInvocation:(NSInvocation *)anInvocation { 41 | if (!_argument) { 42 | NSMethodSignature *signature = [anInvocation methodSignature]; 43 | const char *objCType = [signature messageArgumentTypeAtIndex:_argumentIndex]; 44 | if (KWObjCTypeIsObject(objCType) || KWObjCTypeIsClass(objCType)) { 45 | void* argumentBuffer = NULL; 46 | [anInvocation getMessageArgument:&argumentBuffer atIndex:_argumentIndex]; 47 | id argument = (__bridge id)argumentBuffer; 48 | if (KWObjCTypeIsBlock(objCType)) { 49 | _argument = [argument copy]; 50 | } else { 51 | if(argument == nil) { 52 | _argument = [KWNull null]; 53 | } else { 54 | _argument = argument; 55 | } 56 | } 57 | } else { 58 | NSData *data = [anInvocation messageArgumentDataAtIndex:_argumentIndex]; 59 | _argument = [KWValue valueWithBytes:[data bytes] objCType:objCType]; 60 | } 61 | } 62 | } 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWCountType.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | enum { 10 | KWCountTypeExact, 11 | KWCountTypeAtLeast, 12 | KWCountTypeAtMost 13 | }; 14 | 15 | typedef NSUInteger KWCountType; 16 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWDeviceInfo.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @interface KWDeviceInfo : NSObject 10 | 11 | #pragma mark - Getting the Device Type 12 | 13 | + (BOOL)isSimulator; 14 | + (BOOL)isPhysical; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWDeviceInfo.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWDeviceInfo.h" 8 | 9 | #if TARGET_IPHONE_SIMULATOR 10 | 11 | #import 12 | 13 | #endif // #if TARGET_IPHONE_SIMULATOR 14 | 15 | @implementation KWDeviceInfo 16 | 17 | #pragma mark - Getting the Device Type 18 | 19 | + (BOOL)isSimulator { 20 | #if TARGET_IPHONE_SIMULATOR 21 | return YES; 22 | #else 23 | return NO; 24 | #endif // #if TARGET_IPHONE_SIMULATOR 25 | } 26 | 27 | + (BOOL)isPhysical { 28 | return ![self isSimulator]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWExampleDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWExampleGroupDelegate.h 3 | // Kiwi 4 | // 5 | // Created by Luke Redpath on 08/09/2011. 6 | // Copyright 2011 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class KWExample; 12 | @class KWFailure; 13 | 14 | @protocol KWExampleDelegate 15 | 16 | - (void)example:(KWExample *)example didFailWithFailure:(KWFailure *)failure; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWExampleNodeVisitor.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @class KWAfterAllNode; 10 | @class KWAfterEachNode; 11 | @class KWBeforeAllNode; 12 | @class KWBeforeEachNode; 13 | @class KWContextNode; 14 | @class KWLetNode; 15 | @class KWItNode; 16 | @class KWPendingNode; 17 | @class KWRegisterMatchersNode; 18 | 19 | @protocol KWExampleNodeVisitor 20 | 21 | #pragma mark - Visiting Nodes 22 | 23 | @optional 24 | 25 | - (void)visitContextNode:(KWContextNode *)aNode; 26 | - (void)visitRegisterMatchersNode:(KWRegisterMatchersNode *)aNode; 27 | - (void)visitBeforeAllNode:(KWBeforeAllNode *)aNode; 28 | - (void)visitAfterAllNode:(KWAfterAllNode *)aNode; 29 | - (void)visitBeforeEachNode:(KWBeforeEachNode *)aNode; 30 | - (void)visitAfterEachNode:(KWAfterEachNode *)aNode; 31 | - (void)visitLetNode:(KWLetNode *)aNode; 32 | - (void)visitItNode:(KWItNode *)aNode; 33 | - (void)visitPendingNode:(KWPendingNode *)aNode; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWExampleSuite.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWExampleSuite.h 3 | // Kiwi 4 | // 5 | // Created by Luke Redpath on 17/10/2011. 6 | // Copyright (c) 2011 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KWExampleNodeVisitor.h" 11 | 12 | @class KWContextNode; 13 | @class KWExample; 14 | 15 | @interface KWExampleSuite : NSObject 16 | 17 | - (id)initWithRootNode:(KWContextNode *)contextNode; 18 | - (void)addExample:(KWExample *)example; 19 | - (void)markLastExampleAsLastInContext:(KWContextNode *)context; 20 | 21 | @property (nonatomic, readonly) NSMutableArray *examples; 22 | 23 | #pragma mark - Example selector names 24 | 25 | - (NSString *)nextUniqueSelectorName:(NSString *)name; 26 | 27 | @end 28 | 29 | @interface NSInvocation (KWExampleGroup) 30 | @property (nonatomic, setter = kw_setExample:) KWExample *kw_example; 31 | @end 32 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWExampleSuite.m: -------------------------------------------------------------------------------- 1 | // 2 | // KWExampleSuite.m 3 | // Kiwi 4 | // 5 | // Created by Luke Redpath on 17/10/2011. 6 | // Copyright (c) 2011 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import "KWExampleSuite.h" 10 | 11 | #import "KWAfterAllNode.h" 12 | #import "KWBeforeAllNode.h" 13 | #import "KWContextNode.h" 14 | #import "KWExample.h" 15 | #import "KWStringUtilities.h" 16 | #import "NSMethodSignature+KiwiAdditions.h" 17 | #import 18 | 19 | #define kKWINVOCATION_EXAMPLE_GROUP_KEY @"__KWExampleGroupKey" 20 | 21 | @interface KWExampleSuite() 22 | 23 | @property (nonatomic, strong) KWContextNode *rootNode; 24 | @property (nonatomic, strong) NSMutableArray *examples; 25 | @property (nonatomic, strong) NSMutableDictionary *selectorNameCache; 26 | 27 | @end 28 | 29 | @implementation KWExampleSuite 30 | 31 | - (id)initWithRootNode:(KWContextNode *)contextNode { 32 | self = [super init]; 33 | if (self) { 34 | _rootNode = contextNode; 35 | _examples = [[NSMutableArray alloc] init]; 36 | _selectorNameCache = [[NSMutableDictionary alloc] init]; 37 | } 38 | return self; 39 | } 40 | 41 | 42 | - (void)addExample:(KWExample *)example { 43 | [self.examples addObject:example]; 44 | example.suite = self; 45 | } 46 | 47 | - (void)markLastExampleAsLastInContext:(KWContextNode *)context 48 | { 49 | if ([self.examples count] > 0) { 50 | KWExample *lastExample = (KWExample *)[self.examples lastObject]; 51 | [lastExample.lastInContexts addObject:context]; 52 | } 53 | } 54 | 55 | #pragma mark - Example selector names 56 | 57 | - (NSString *)nextUniqueSelectorName:(NSString *)name { 58 | NSUInteger count = [(self.selectorNameCache[name] ?: @1) integerValue]; 59 | NSString *uniqueName = name; 60 | if (count > 1) { 61 | NSString *format = [name hasSuffix:@"_"] ? @"%lu" : @"_%lu"; 62 | uniqueName = [name stringByAppendingFormat:format, (unsigned long)count]; 63 | } 64 | self.selectorNameCache[name] = @(++count); 65 | return uniqueName; 66 | } 67 | 68 | #pragma mark - NSFastEnumeration 69 | 70 | - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(__unsafe_unretained id [])buffer count:(NSUInteger)len { 71 | return [self.examples countByEnumeratingWithState:state objects:buffer count:len]; 72 | } 73 | 74 | @end 75 | 76 | #pragma mark - 77 | 78 | // because XCTest will modify the invocation target, we'll have to store 79 | // another reference to the example group so we can retrieve it later 80 | 81 | @implementation NSInvocation (KWExampleGroup) 82 | 83 | - (void)kw_setExample:(KWExample *)exampleGroup { 84 | objc_setAssociatedObject(self, kKWINVOCATION_EXAMPLE_GROUP_KEY, exampleGroup, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 85 | } 86 | 87 | - (KWExample *)kw_example { 88 | return objc_getAssociatedObject(self, kKWINVOCATION_EXAMPLE_GROUP_KEY); 89 | } 90 | 91 | @end 92 | 93 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWExampleSuiteBuilder.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWBlock.h" 9 | 10 | @class KWCallSite; 11 | @class KWExample; 12 | @class KWExampleSuite; 13 | @class KWContextNode; 14 | 15 | @interface KWExampleSuiteBuilder : NSObject 16 | 17 | #pragma mark - Initializing 18 | 19 | + (id)sharedExampleSuiteBuilder; 20 | 21 | #pragma mark - Building Example Groups 22 | 23 | @property (nonatomic, readonly) BOOL isBuildingExampleSuite; 24 | @property (nonatomic, strong, readonly) KWExampleSuite *currentExampleSuite; 25 | @property (nonatomic, strong) KWExample *currentExample; 26 | @property (nonatomic, strong) KWCallSite *focusedCallSite; 27 | 28 | //spec file name:line number of callsite 29 | - (void)focusWithURI:(NSString *)nodeUrl; 30 | - (KWExampleSuite *)buildExampleSuite:(void (^)(void))buildingBlock; 31 | 32 | - (void)pushContextNodeWithCallSite:(KWCallSite *)aCallSite description:(NSString *)aDescription; 33 | - (void)popContextNode; 34 | - (void)setRegisterMatchersNodeWithCallSite:(KWCallSite *)aCallSite namespacePrefix:(NSString *)aNamespacePrefix; 35 | - (void)setBeforeAllNodeWithCallSite:(KWCallSite *)aCallSite block:(void (^)(void))block; 36 | - (void)setAfterAllNodeWithCallSite:(KWCallSite *)aCallSite block:(void (^)(void))block; 37 | - (void)setBeforeEachNodeWithCallSite:(KWCallSite *)aCallSite block:(void (^)(void))block; 38 | - (void)setAfterEachNodeWithCallSite:(KWCallSite *)aCallSite block:(void (^)(void))block; 39 | - (void)addLetNodeWithCallSite:(KWCallSite *)aCallSite objectRef:(id *)anObjectRef symbolName:(NSString *)aSymbolName block:(id (^)(void))block; 40 | - (void)addItNodeWithCallSite:(KWCallSite *)aCallSite description:(NSString *)aDescription block:(void (^)(void))block; 41 | - (void)addPendingNodeWithCallSite:(KWCallSite *)aCallSite description:(NSString *)aDescription; 42 | 43 | - (BOOL)isFocused; 44 | - (BOOL)foundFocus; 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWExpectationType.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | enum { 10 | KWExpectationTypeShould, 11 | KWExpectationTypeShouldNot, 12 | KWExpectationTypeMaybe 13 | }; 14 | 15 | typedef NSUInteger KWExpectationType; 16 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWFailure.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @class KWCallSite; 10 | 11 | @interface KWFailure : NSObject 12 | 13 | #pragma mark - Initializing 14 | 15 | - (id)initWithCallSite:(KWCallSite *)aCallSite message:(NSString *)aMessage; 16 | - (id)initWithCallSite:(KWCallSite *)aCallSite format:(NSString *)format, ...; 17 | 18 | + (id)failureWithCallSite:(KWCallSite *)aCallSite message:(NSString *)aMessage; 19 | + (id)failureWithCallSite:(KWCallSite *)aCallSite format:(NSString *)format, ...; 20 | 21 | #pragma mark - Properties 22 | 23 | @property (nonatomic, readonly) NSString *message; 24 | @property (nonatomic, weak, readonly) KWCallSite *callSite; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWFailure.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWFailure.h" 8 | #import "KWCallSite.h" 9 | 10 | @implementation KWFailure 11 | 12 | #pragma mark - Initializing 13 | 14 | - (id)initWithCallSite:(KWCallSite *)aCallSite message:(NSString *)aMessage { 15 | self = [super init]; 16 | if (self) { 17 | _callSite = aCallSite; 18 | _message = [aMessage copy]; 19 | } 20 | 21 | return self; 22 | } 23 | 24 | - (id)initWithCallSite:(KWCallSite *)aCallSite format:(NSString *)format, ... { 25 | va_list argumentList; 26 | va_start(argumentList, format); 27 | NSString *aMessage = [[NSString alloc] initWithFormat:format arguments:argumentList]; 28 | va_end(argumentList); 29 | return [self initWithCallSite:aCallSite message:aMessage]; 30 | } 31 | 32 | + (id)failureWithCallSite:(KWCallSite *)aCallSite message:(NSString *)aMessage { 33 | return [[self alloc] initWithCallSite:aCallSite message:aMessage]; 34 | } 35 | 36 | + (id)failureWithCallSite:(KWCallSite *)aCallSite format:(NSString *)format, ... { 37 | va_list argumentList; 38 | va_start(argumentList, format); 39 | NSString *message = [[NSString alloc] initWithFormat:format arguments:argumentList]; 40 | va_end(argumentList); 41 | return [self failureWithCallSite:aCallSite message:message]; 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWFormatter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @interface KWFormatter : NSObject 10 | 11 | #pragma mark - Getting Descriptions 12 | 13 | + (NSString *)formatObject:(id)anObject; 14 | + (NSString *)formatObjectIncludingClass:(id)anObject; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWFormatter.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWFormatter.h" 8 | 9 | @implementation KWFormatter 10 | 11 | 12 | #pragma mark - Getting Descriptions 13 | 14 | + (NSString *)formatObject:(id)anObject { 15 | if ([anObject isKindOfClass:[NSString class]]) 16 | return [NSString stringWithFormat:@"\"%@\"", anObject]; 17 | 18 | else if ([anObject isKindOfClass:[NSDictionary class]]) 19 | return [anObject description]; // NSDictionary conforms to NSFastEnumeration 20 | 21 | else if ([anObject conformsToProtocol:@protocol(NSFastEnumeration)]) 22 | return [self formattedCollection:anObject]; 23 | 24 | return [anObject description]; 25 | } 26 | 27 | + (NSString *)formatObjectIncludingClass:(id)anObject { 28 | NSString *classString = [[anObject class] description]; 29 | 30 | if ([anObject isKindOfClass:[NSString class]]) 31 | classString = @"NSString"; 32 | 33 | return [NSString stringWithFormat:@"(%@) %@", classString, [self formatObject:anObject]]; 34 | } 35 | 36 | 37 | #pragma mark - Internal Methods 38 | 39 | + (NSString *)formattedCollection:(id)collection { 40 | 41 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"("]; 42 | NSUInteger index = 0; 43 | 44 | for (id object in collection) { 45 | if (index == 0) 46 | [description appendFormat:@"%@", [self formatObject:object]]; 47 | else 48 | [description appendFormat:@", %@", [self formatObject:object]]; 49 | 50 | ++index; 51 | } 52 | 53 | [description appendString:@")"]; 54 | return description; 55 | } 56 | 57 | 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWFutureObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWFutureObject.h 3 | // iOSFalconCore 4 | // 5 | // Created by Luke Redpath on 13/01/2011. 6 | // Copyright 2011 LJR Software Limited. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef id (^KWFutureObjectBlock)(void); 12 | 13 | @interface KWFutureObject : NSObject 14 | 15 | + (id)objectWithObjectPointer:(id *)pointer; 16 | + (id)futureObjectWithBlock:(KWFutureObjectBlock)block; 17 | - (id)initWithBlock:(KWFutureObjectBlock)aBlock; 18 | - (id)object; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWFutureObject.m: -------------------------------------------------------------------------------- 1 | // 2 | // KWFutureObject.m 3 | // iOSFalconCore 4 | // 5 | // Created by Luke Redpath on 13/01/2011. 6 | // Copyright 2011 LJR Software Limited. All rights reserved. 7 | // 8 | 9 | #import "KWFutureObject.h" 10 | 11 | @interface KWFutureObject() 12 | 13 | @property (nonatomic, strong) KWFutureObjectBlock block; 14 | 15 | @end 16 | 17 | @implementation KWFutureObject 18 | 19 | + (id)objectWithObjectPointer:(id __autoreleasing *)pointer { 20 | return [self futureObjectWithBlock:^{ return *pointer; }]; 21 | } 22 | 23 | + (id)futureObjectWithBlock:(KWFutureObjectBlock)block { 24 | return [[self alloc] initWithBlock:block]; 25 | } 26 | 27 | - (id)initWithBlock:(KWFutureObjectBlock)aBlock { 28 | self = [super init]; 29 | if (self) { 30 | _block = [aBlock copy]; 31 | } 32 | return self; 33 | } 34 | 35 | - (id)object; { 36 | return self.block(); 37 | } 38 | 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWInvocationCapturer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @protocol KWInvocationCapturerDelegate; 10 | 11 | @interface KWInvocationCapturer : NSProxy 12 | 13 | #pragma mark - Initializing 14 | 15 | - (id)initWithDelegate:(id)aDelegate; 16 | - (id)initWithDelegate:(id)aDelegate userInfo:(NSDictionary *)aUserInfo; 17 | 18 | + (id)invocationCapturerWithDelegate:(id)aDelegate; 19 | + (id)invocationCapturerWithDelegate:(id)aDelegate userInfo:(NSDictionary *)aUserInfo; 20 | 21 | #pragma mark - Properties 22 | 23 | @property (nonatomic, weak, readonly) id delegate; 24 | @property (nonatomic, strong, readonly) NSDictionary *userInfo; 25 | 26 | @end 27 | 28 | @protocol KWInvocationCapturerDelegate 29 | 30 | #pragma mark - Capturing Invocations 31 | 32 | - (NSMethodSignature *)invocationCapturer:(KWInvocationCapturer *)anInvocationCapturer methodSignatureForSelector:(SEL)aSelector; 33 | - (void)invocationCapturer:(KWInvocationCapturer *)anInvocationCapturer didCaptureInvocation:(NSInvocation *)anInvocation; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWInvocationCapturer.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWInvocationCapturer.h" 8 | #import "KWWorkarounds.h" 9 | #import "NSInvocation+KiwiAdditions.h" 10 | 11 | @implementation KWInvocationCapturer 12 | 13 | #pragma mark - Initializing 14 | 15 | - (id)initWithDelegate:(id)aDelegate { 16 | return [self initWithDelegate:aDelegate userInfo:nil]; 17 | } 18 | 19 | - (id)initWithDelegate:(id)aDelegate userInfo:(NSDictionary *)aUserInfo { 20 | delegate = aDelegate; 21 | userInfo = aUserInfo; 22 | return self; 23 | } 24 | 25 | + (id)invocationCapturerWithDelegate:(id)aDelegate { 26 | return [self invocationCapturerWithDelegate:aDelegate userInfo:nil]; 27 | } 28 | 29 | + (id)invocationCapturerWithDelegate:(id)aDelegate userInfo:(NSDictionary *)aUserInfo { 30 | return [[self alloc] initWithDelegate:aDelegate userInfo:aUserInfo]; 31 | } 32 | 33 | 34 | #pragma mark - Properties 35 | 36 | @synthesize delegate; 37 | @synthesize userInfo; 38 | 39 | #pragma mark - Capturing Invocations 40 | 41 | - (void)KW_captureInvocation:(NSInvocation *)anInvocation { 42 | [self.delegate invocationCapturer:self didCaptureInvocation:anInvocation]; 43 | } 44 | 45 | #pragma mark - Handling Invocations 46 | 47 | - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector { 48 | return [self.delegate invocationCapturer:self methodSignatureForSelector:aSelector]; 49 | } 50 | 51 | - (void)forwardInvocation:(NSInvocation *)anInvocation { 52 | #if KW_TARGET_HAS_INVOCATION_EXCEPTION_BUG 53 | @try { 54 | #endif // #if KW_TARGET_HAS_INVOCATION_EXCEPTION_BUG 55 | 56 | [self KW_captureInvocation:anInvocation]; 57 | 58 | #if KW_TARGET_HAS_INVOCATION_EXCEPTION_BUG 59 | } @catch (NSException *exception) { 60 | KWSetExceptionFromAcrossInvocationBoundary(exception); 61 | } 62 | #endif // #if KW_TARGET_HAS_INVOCATION_EXCEPTION_BUG 63 | } 64 | 65 | #pragma mark - Whitelisted NSObject Methods 66 | 67 | // The return values from these methods should never be needed, so just call 68 | // the super implementation after capturing the invocation. 69 | 70 | - (BOOL)isEqual:(id)anObject { 71 | NSInvocation *invocation = [NSInvocation invocationWithTarget:self selector:_cmd messageArguments:&anObject]; 72 | [self KW_captureInvocation:invocation]; 73 | return [super isEqual:anObject]; 74 | } 75 | 76 | - (NSUInteger)hash { 77 | NSInvocation *invocation = [NSInvocation invocationWithTarget:self selector:_cmd]; 78 | [self KW_captureInvocation:invocation]; 79 | return [super hash]; 80 | } 81 | 82 | - (NSString *)description { 83 | NSInvocation *invocation = [NSInvocation invocationWithTarget:self selector:_cmd]; 84 | [self KW_captureInvocation:invocation]; 85 | return [super description]; 86 | } 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWLet.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #if __has_feature(objc_arc) 8 | # define KW_ARC_AUTORELEASE(obj) obj 9 | #else 10 | # define KW_ARC_AUTORELEASE(obj) [obj autorelease] 11 | #endif 12 | 13 | #define KW_LET_REF(var) \ 14 | (__autoreleasing id *) \ 15 | ( (void *(^)(void)) KW_ARC_AUTORELEASE([^{ void *ref = &var; return ref; } copy]) )() 16 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatching.h" 9 | 10 | @interface KWMatcher : NSObject 11 | 12 | #pragma mark - Initializing 13 | 14 | - (id)initWithSubject:(id)anObject; 15 | 16 | + (id)matcherWithSubject:(id)anObject; 17 | 18 | #pragma mark - Properties 19 | 20 | @property (nonatomic, strong) id subject; 21 | 22 | #pragma mark - Getting Matcher Strings 23 | 24 | + (NSArray *)matcherStrings; 25 | 26 | #pragma mark - Getting Matcher Compatability 27 | 28 | + (BOOL)canMatchSubject:(id)anObject; 29 | 30 | #pragma mark - Matching 31 | 32 | - (BOOL)evaluate; 33 | 34 | #pragma mark - Getting Failure Messages 35 | 36 | - (NSString *)failureMessageForShould; 37 | - (NSString *)failureMessageForShouldNot; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWMatcher.h" 8 | #import "KWFormatter.h" 9 | #import "KWFutureObject.h" 10 | 11 | @implementation KWMatcher 12 | 13 | #pragma mark - Initializing 14 | 15 | - (id)initWithSubject:(id)anObject { 16 | self = [super init]; 17 | if (self) { 18 | _subject = anObject; 19 | } 20 | 21 | return self; 22 | } 23 | 24 | + (id)matcherWithSubject:(id)anObject { 25 | return [[self alloc] initWithSubject:anObject]; 26 | } 27 | 28 | 29 | #pragma mark - Properties 30 | 31 | - (id)subject 32 | { 33 | if ([_subject isKindOfClass:[KWFutureObject class]]) { 34 | return [(KWFutureObject *)_subject object]; 35 | } 36 | return _subject; 37 | } 38 | 39 | #pragma mark - Getting Matcher Strings 40 | 41 | + (NSArray *)matcherStrings { 42 | return nil; 43 | } 44 | 45 | #pragma mark - Getting Matcher Compatability 46 | 47 | + (BOOL)canMatchSubject:(id)anObject { 48 | return YES; 49 | } 50 | 51 | #pragma mark - Matching 52 | 53 | - (BOOL)evaluate { 54 | [NSException raise:NSInternalInconsistencyException format:@"%@ must override -evaluate", 55 | [KWFormatter formatObject:[self class]]]; 56 | return NO; 57 | } 58 | 59 | #pragma mark - Getting Failure Messages 60 | 61 | - (NSString *)failureMessageForShould { 62 | return @"subject did not meet expectation"; 63 | } 64 | 65 | - (NSString *)failureMessageForShouldNot { 66 | NSString *failureMessageForShould = [self failureMessageForShould]; 67 | NSRange markerRange = [failureMessageForShould rangeOfString:@" to "]; 68 | 69 | if (markerRange.location == NSNotFound) 70 | return @"subject did not meet expectation"; 71 | 72 | NSRange replacementRange = NSMakeRange(0, markerRange.location + markerRange.length); 73 | NSString *message = [failureMessageForShould stringByReplacingOccurrencesOfString:@" to " 74 | withString:@" not to " 75 | options:0 76 | range:replacementRange]; 77 | return message; 78 | } 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWMatcherFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatching.h" 9 | 10 | @class KWFailure; 11 | @class KWMatcher; 12 | @class KWUserDefinedMatcherBuilder; 13 | 14 | @interface KWMatcherFactory : NSObject 15 | 16 | #pragma mark - Initializing 17 | 18 | - (id)init; 19 | 20 | #pragma mark - Properties 21 | 22 | @property (nonatomic, readonly) NSArray *registeredMatcherClasses; 23 | 24 | #pragma mark - Registering Matcher Classes 25 | 26 | - (void)registerMatcherClass:(Class)aClass; 27 | - (void)registerMatcherClassesWithNamespacePrefix:(NSString *)aNamespacePrefix; 28 | 29 | #pragma mark - Getting Method Signatures 30 | 31 | - (NSMethodSignature *)methodSignatureForMatcherSelector:(SEL)aSelector; 32 | 33 | #pragma mark - Getting Matchers 34 | 35 | - (KWMatcher *)matcherFromInvocation:(NSInvocation *)anInvocation subject:(id)subject; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWMatchers.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWMatchers.h 3 | // Kiwi 4 | // 5 | // Created by Luke Redpath on 17/06/2011. 6 | // Copyright 2011 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class KWUserDefinedMatcherBuilder; 12 | 13 | typedef void (^KWMatchersBuildingBlock)(KWUserDefinedMatcherBuilder *matcherBuilder); 14 | 15 | @class KWUserDefinedMatcher; 16 | 17 | @interface KWMatchers : NSObject 18 | 19 | + (id)matchers; 20 | 21 | #pragma mark - Defining Matchers 22 | 23 | + (void)defineMatcher:(NSString *)selectorString as:(KWMatchersBuildingBlock)block; 24 | - (void)defineMatcher:(NSString *)selectorString as:(KWMatchersBuildingBlock)block; 25 | - (void)addUserDefinedMatcherBuilder:(KWUserDefinedMatcherBuilder *)builder; 26 | 27 | #pragma mark - Building Matchers 28 | 29 | - (KWUserDefinedMatcher *)matcherForSelector:(SEL)selector subject:(id)subject; 30 | @end 31 | 32 | void KWDefineMatchers(NSString *selectorString, KWMatchersBuildingBlock block); 33 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWMatchers.m: -------------------------------------------------------------------------------- 1 | // 2 | // KWMatchers.m 3 | // Kiwi 4 | // 5 | // Created by Luke Redpath on 17/06/2011. 6 | // Copyright 2011 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import "KWMatchers.h" 10 | #import "KWUserDefinedMatcher.h" 11 | 12 | @interface KWMatchers() { 13 | NSMutableDictionary *userDefinedMatchers; 14 | } 15 | @end 16 | 17 | @implementation KWMatchers 18 | 19 | #pragma mark - Singleton implementation 20 | 21 | static id sharedMatchers = nil; 22 | 23 | + (void)initialize { 24 | if (self == [KWMatchers class]) { 25 | sharedMatchers = [[self alloc] init]; 26 | } 27 | } 28 | 29 | + (id)matchers { 30 | return sharedMatchers; 31 | } 32 | 33 | - (id)init { 34 | self = [super init]; 35 | if (self) { 36 | userDefinedMatchers = [[NSMutableDictionary alloc] init]; 37 | } 38 | return self; 39 | } 40 | 41 | #pragma mark - Defining Matchers 42 | 43 | + (void)defineMatcher:(NSString *)selectorString as:(KWMatchersBuildingBlock)block { 44 | [[self matchers] defineMatcher:selectorString as:block]; 45 | } 46 | 47 | - (void)defineMatcher:(NSString *)selectorString as:(KWMatchersBuildingBlock)block { 48 | KWUserDefinedMatcherBuilder *builder = [KWUserDefinedMatcherBuilder builderForSelector:NSSelectorFromString(selectorString)]; 49 | block(builder); 50 | userDefinedMatchers[builder.key] = builder; 51 | } 52 | 53 | - (void)addUserDefinedMatcherBuilder:(KWUserDefinedMatcherBuilder *)builder { 54 | userDefinedMatchers[builder.key] = builder; 55 | } 56 | 57 | #pragma mark - Building Matchers 58 | 59 | - (KWUserDefinedMatcher *)matcherForSelector:(SEL)selector subject:(id)subject { 60 | KWUserDefinedMatcherBuilder *builder = userDefinedMatchers[NSStringFromSelector(selector)]; 61 | 62 | if (builder == nil) 63 | return nil; 64 | 65 | return [builder buildMatcherWithSubject:subject]; 66 | } 67 | 68 | 69 | @end 70 | 71 | void KWDefineMatchers(NSString *selectorString, KWMatchersBuildingBlock block) 72 | { 73 | [KWMatchers defineMatcher:selectorString as:block]; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWMatching.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @protocol KWMatching 10 | 11 | #pragma mark - Initializing 12 | 13 | - (id)initWithSubject:(id)anObject; 14 | 15 | #pragma mark - Getting Matcher Strings 16 | 17 | + (NSArray *)matcherStrings; 18 | 19 | #pragma mark - Getting Matcher Compatability 20 | 21 | + (BOOL)canMatchSubject:(id)anObject; 22 | 23 | #pragma mark - Matching 24 | 25 | @optional 26 | 27 | - (BOOL)isNilMatcher; 28 | - (BOOL)shouldBeEvaluatedAtEndOfExample; 29 | - (BOOL)willEvaluateMultipleTimes; 30 | - (void)setWillEvaluateMultipleTimes:(BOOL)shouldEvaluateMultipleTimes; 31 | - (void)setWillEvaluateAgainstNegativeExpectation:(BOOL)willEvaluateAgainstNegativeExpectation; 32 | 33 | @required 34 | 35 | - (BOOL)evaluate; 36 | 37 | #pragma mark - Getting Failure Messages 38 | 39 | - (NSString *)failureMessageForShould; 40 | - (NSString *)failureMessageForShouldNot; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWMessagePattern.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @interface KWMessagePattern : NSObject 10 | 11 | #pragma mark - Initializing 12 | 13 | - (id)initWithSelector:(SEL)aSelector; 14 | - (id)initWithSelector:(SEL)aSelector argumentFilters:(NSArray *)anArray; 15 | - (id)initWithSelector:(SEL)aSelector firstArgumentFilter:(id)firstArgumentFilter argumentList:(va_list)argumentList; 16 | 17 | + (id)messagePatternWithSelector:(SEL)aSelector; 18 | + (id)messagePatternWithSelector:(SEL)aSelector argumentFilters:(NSArray *)anArray; 19 | + (id)messagePatternWithSelector:(SEL)aSelector firstArgumentFilter:(id)firstArgumentFilter argumentList:(va_list)argumentList; 20 | 21 | + (id)messagePatternFromInvocation:(NSInvocation *)anInvocation; 22 | 23 | #pragma mark - Properties 24 | 25 | @property (nonatomic, readonly) SEL selector; 26 | @property (nonatomic, readonly) NSArray *argumentFilters; 27 | 28 | #pragma mark - Matching Invocations 29 | 30 | - (BOOL)matchesInvocation:(NSInvocation *)anInvocation; 31 | 32 | #pragma mark - Comparing Message Patterns 33 | 34 | - (BOOL)isEqualToMessagePattern:(KWMessagePattern *)aMessagePattern; 35 | 36 | #pragma mark - Retrieving String Representations 37 | 38 | - (NSString *)stringValue; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWMessageSpying.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @protocol KWMessageSpying 10 | 11 | #pragma mark - Spying on Messages 12 | 13 | - (void)object:(id)anObject didReceiveInvocation:(NSInvocation *)anInvocation; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWMessageTracker.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWCountType.h" 9 | #import "KWMessageSpying.h" 10 | 11 | @class KWMessagePattern; 12 | 13 | @interface KWMessageTracker : NSObject 14 | 15 | #pragma mark - Initializing 16 | 17 | - (id)initWithSubject:(id)anObject messagePattern:(KWMessagePattern *)aMessagePattern countType:(KWCountType)aCountType count:(NSUInteger)aCount; 18 | 19 | + (id)messageTrackerWithSubject:(id)anObject messagePattern:(KWMessagePattern *)aMessagePattern countType:(KWCountType)aCountType count:(NSUInteger)aCount; 20 | 21 | #pragma mark - Properties 22 | 23 | @property (nonatomic, readonly) id subject; 24 | @property (nonatomic, readonly) KWMessagePattern *messagePattern; 25 | @property (nonatomic, readonly) KWCountType countType; 26 | @property (nonatomic, readonly) NSUInteger count; 27 | 28 | #pragma mark - Stopping Tracking 29 | 30 | - (void)stopTracking; 31 | 32 | #pragma mark - Getting Message Tracker Status 33 | 34 | - (BOOL)succeeded; 35 | 36 | #pragma mark - Getting Phrases 37 | 38 | - (NSString *)expectedCountPhrase; 39 | - (NSString *)receivedCountPhrase; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWNull.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | // KWNull exists to represent the same thing as NSNull, except that Kiwi needs 10 | // to distinguish between null singletons used internally and those a user 11 | // is using as an object parameter. 12 | @interface KWNull : NSObject 13 | 14 | #pragma mark - Initializing 15 | 16 | + (id)null; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWNull.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWNull.h" 8 | 9 | @implementation KWNull 10 | 11 | #pragma mark - Initializing 12 | 13 | 14 | + (id)null { 15 | static KWNull *sharedNull = nil; 16 | static dispatch_once_t onceToken; 17 | dispatch_once(&onceToken, ^{ 18 | sharedNull = [self new]; 19 | 20 | }); 21 | 22 | return sharedNull; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWObjCUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | #pragma mark - Objective-C Type Utilities 10 | 11 | BOOL KWObjCTypeEqualToObjCType(const char *firstObjCType, const char *secondObjCType); 12 | BOOL KWObjCTypeIsNumeric(const char *objCType); 13 | BOOL KWObjCTypeIsFloatingPoint(const char *objCType); 14 | BOOL KWObjCTypeIsIntegral(const char *objCType); 15 | BOOL KWObjCTypeIsSignedIntegral(const char *objCType); 16 | BOOL KWObjCTypeIsUnsignedIntegral(const char *objCType); 17 | BOOL KWObjCTypeIsBoolean(const char *objCType); 18 | BOOL KWObjCTypeIsObject(const char *objCType); 19 | BOOL KWObjCTypeIsCharString(const char *objCType); 20 | BOOL KWObjCTypeIsClass(const char *objCType); 21 | BOOL KWObjCTypeIsSelector(const char *objCType); 22 | BOOL KWObjCTypeIsPointerToType(const char *objCType); 23 | BOOL KWObjCTypeIsPointerLike(const char *objCType); 24 | BOOL KWObjCTypeIsUnknown(const char *objCType); 25 | BOOL KWObjCTypeIsBlock(const char *objCType); 26 | 27 | NSUInteger KWObjCTypeLength(const char *objCType); 28 | 29 | #pragma mark - Selector Utlities 30 | 31 | NSUInteger KWSelectorParameterCount(SEL selector); 32 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWProbe.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWProbe.h 3 | // iOSFalconCore 4 | // 5 | // Created by Luke Redpath on 13/01/2011. 6 | // Copyright 2011 LJR Software Limited. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol KWProbe 12 | - (BOOL)isSatisfied; 13 | - (void)sample; 14 | @end 15 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWProbePoller.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWProbePoller.h 3 | // iOSFalconCore 4 | // 5 | // Created by Luke Redpath on 13/01/2011. 6 | // Copyright 2011 LJR Software Limited. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KWProbe.h" 11 | 12 | #define kKW_DEFAULT_PROBE_DELAY 0.1 13 | 14 | @interface KWProbePoller : NSObject 15 | 16 | - (id)initWithTimeout:(NSTimeInterval)theTimeout delay:(NSTimeInterval)theDelay shouldWait:(BOOL)wait; 17 | - (BOOL)check:(id)probe; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWProbePoller.m: -------------------------------------------------------------------------------- 1 | // 2 | // KWProbePoller.m 3 | // iOSFalconCore 4 | // 5 | // Created by Luke Redpath on 13/01/2011. 6 | // Copyright 2011 LJR Software Limited. All rights reserved. 7 | // 8 | 9 | #import "KWProbePoller.h" 10 | 11 | @interface KWTimeout : NSObject 12 | 13 | @property (nonatomic) CFTimeInterval timeoutDateStamp; 14 | 15 | @end 16 | 17 | @implementation KWTimeout 18 | 19 | - (id)initWithTimeout:(NSTimeInterval)timeout 20 | { 21 | self = [super init]; 22 | if (self) { 23 | _timeoutDateStamp = CFAbsoluteTimeGetCurrent() + timeout; 24 | } 25 | return self; 26 | } 27 | 28 | 29 | - (BOOL)hasTimedOut { 30 | return (_timeoutDateStamp - CFAbsoluteTimeGetCurrent()) < 0; 31 | } 32 | 33 | @end 34 | 35 | 36 | @interface KWProbePoller() 37 | 38 | @property (nonatomic, assign) NSTimeInterval timeoutInterval; 39 | @property (nonatomic, assign) NSTimeInterval delayInterval; 40 | @property (nonatomic, assign) BOOL shouldWait; 41 | 42 | @end 43 | 44 | @implementation KWProbePoller 45 | 46 | - (id)initWithTimeout:(NSTimeInterval)theTimeout 47 | delay:(NSTimeInterval)theDelay 48 | shouldWait:(BOOL)wait { 49 | self = [super init]; 50 | if (self) { 51 | _timeoutInterval = theTimeout; 52 | _delayInterval = theDelay; 53 | _shouldWait = wait; 54 | } 55 | return self; 56 | } 57 | 58 | - (BOOL)check:(id)probe; { 59 | KWTimeout *timeout = [[KWTimeout alloc] initWithTimeout:self.timeoutInterval]; 60 | 61 | while (self.shouldWait || ![probe isSatisfied]) { 62 | if ([timeout hasTimedOut]) { 63 | return [probe isSatisfied]; 64 | } 65 | CFRunLoopRunInMode(kCFRunLoopDefaultMode, _delayInterval, false); 66 | [probe sample]; 67 | } 68 | 69 | return YES; 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWReporting.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @class KWFailure; 10 | 11 | @protocol KWReporting 12 | 13 | #pragma mark - Reporting Failures 14 | 15 | - (void)reportFailure:(KWFailure *)failure; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWSpec.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import 9 | #import "KWExpectationType.h" 10 | #import "KWVerifying.h" 11 | #import "KWExampleDelegate.h" 12 | 13 | @class KWCallSite; 14 | 15 | @interface KWSpec : XCTestCase 16 | 17 | #pragma mark - Adding Verifiers 18 | 19 | + (id)addVerifier:(id)aVerifier; 20 | + (id)addExistVerifierWithExpectationType:(KWExpectationType)anExpectationType callSite:(KWCallSite *)aCallSite; 21 | + (id)addMatchVerifierWithExpectationType:(KWExpectationType)anExpectationType callSite:(KWCallSite *)aCallSite; 22 | + (id)addAsyncVerifierWithExpectationType:(KWExpectationType)anExpectationType callSite:(KWCallSite *)aCallSite timeout:(NSTimeInterval)timeout shouldWait:(BOOL)shouldWait; 23 | 24 | #pragma mark - Building Example Groups 25 | 26 | + (NSString *)file; 27 | + (void)buildExampleGroups; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWStringUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | #pragma mark - Checking for Case Separated Words 10 | 11 | BOOL KWStringHasWordPrefix(NSString *string, NSString *prefix); 12 | BOOL KWStringHasStrictWordPrefix(NSString *string, NSString *prefix); 13 | BOOL KWStringHasWord(NSString *string, NSString *word); 14 | 15 | #pragma mark - Getting Type Encodings 16 | 17 | NSString *KWEncodingWithObjCTypes(const char *firstType, ...) NS_REQUIRES_NIL_TERMINATION; 18 | NSString *KWEncodingForDefaultMethod(void); 19 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWStringUtilities.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWStringUtilities.h" 8 | 9 | #pragma mark - Checking for Case Separated Words 10 | 11 | BOOL KWStringHasWordPrefix(NSString *string, NSString *prefix) { 12 | return [string isEqualToString:prefix] || KWStringHasStrictWordPrefix(string, prefix); 13 | } 14 | 15 | BOOL KWStringHasStrictWordPrefix(NSString *string, NSString *prefix) { 16 | if (![string hasPrefix:prefix] || [string length] == [prefix length]) 17 | return NO; 18 | 19 | unichar firstCharacterAfterPrefix = [string characterAtIndex:[prefix length]]; 20 | NSCharacterSet *uppercaseCharacterSet = [NSCharacterSet uppercaseLetterCharacterSet]; 21 | return [uppercaseCharacterSet characterIsMember:firstCharacterAfterPrefix]; 22 | } 23 | 24 | BOOL KWStringHasWord(NSString *string, NSString *word) { 25 | if (KWStringHasWordPrefix(string, word)) 26 | return YES; 27 | 28 | NSCharacterSet *lowercaseCharacterSet = [NSCharacterSet lowercaseLetterCharacterSet]; 29 | NSCharacterSet *uppercaseCharacterSet = [NSCharacterSet uppercaseLetterCharacterSet]; 30 | NSRange searchRange = NSMakeRange(0, [string length]); 31 | 32 | // Never match if word begins with a lowercase letter and was not a prefix. 33 | if ([lowercaseCharacterSet characterIsMember:[word characterAtIndex:0]]) 34 | return NO; 35 | 36 | while (1) { 37 | if (searchRange.location >= [string length]) 38 | return NO; 39 | 40 | NSRange range = [string rangeOfString:word options:0 range:searchRange]; 41 | searchRange.location = range.location + range.length; 42 | searchRange.length = [string length] - searchRange.location; 43 | 44 | if (range.location == NSNotFound) 45 | return NO; 46 | 47 | if (range.location > 0) { 48 | unichar charBeforeRange = [string characterAtIndex:range.location - 1]; 49 | 50 | 51 | if (![lowercaseCharacterSet characterIsMember:charBeforeRange]) 52 | continue; 53 | } 54 | 55 | if (range.location + range.length < [string length]) { 56 | unichar charAfterRange = [string characterAtIndex:range.location + range.length]; 57 | 58 | if (![uppercaseCharacterSet characterIsMember:charAfterRange]) 59 | continue; 60 | } 61 | 62 | return YES; 63 | } 64 | } 65 | 66 | #pragma mark - Getting Type Encodings 67 | 68 | NSString *KWEncodingWithObjCTypes(const char *firstType, ...) { 69 | if (firstType == nil) 70 | return nil; 71 | 72 | NSMutableString *encoding = [NSMutableString stringWithCapacity:8]; 73 | va_list argumentList; 74 | va_start(argumentList, firstType); 75 | const char *type = firstType; 76 | 77 | do { 78 | [encoding appendFormat:@"%s", type]; 79 | type = va_arg(argumentList, const char *); 80 | } while (type != nil); 81 | 82 | va_end(argumentList); 83 | return encoding; 84 | } 85 | 86 | NSString *KWEncodingForDefaultMethod(void) { 87 | return KWEncodingWithObjCTypes(@encode(id), @encode(id), @encode(SEL), nil); 88 | } 89 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWSymbolicator.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWSymbolicator.h 3 | // Kiwi 4 | // 5 | // Created by Jerry Marino on 4/28/13. 6 | // Copyright (c) 2013 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KWSymbolicator.h" 11 | #import "KWCallSite.h" 12 | 13 | long kwCallerAddress(void); 14 | 15 | @interface KWCallSite (KWSymbolication) 16 | 17 | + (KWCallSite *)callSiteWithCallerAddress:(long)address; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWSymbolicator.m: -------------------------------------------------------------------------------- 1 | // 2 | // KWSymbolicator.m 3 | // Kiwi 4 | // 5 | // Created by Jerry Marino on 4/28/13. 6 | // Copyright (c) 2013 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import "KWSymbolicator.h" 13 | #import "KWBackgroundTask.h" 14 | 15 | long kwCallerAddress (void){ 16 | #if !__arm__ 17 | unw_cursor_t cursor; unw_context_t uc; 18 | unw_word_t ip; 19 | 20 | unw_getcontext(&uc); 21 | unw_init_local(&cursor, &uc); 22 | 23 | int pos = 2; 24 | while (unw_step(&cursor) && pos--){ 25 | unw_get_reg (&cursor, UNW_REG_IP, &ip); 26 | if(pos == 0) return (NSUInteger)(ip - 4); 27 | } 28 | #endif 29 | return 0; 30 | } 31 | 32 | @implementation KWCallSite (KWSymbolication) 33 | 34 | static void GetTestBundleExecutablePathSlide(NSString **executablePath, long *slide) { 35 | for (int i = 0; i < _dyld_image_count(); i++) { 36 | if (strstr(_dyld_get_image_name(i), ".octest/") || strstr(_dyld_get_image_name(i), ".xctest/")) { 37 | *executablePath = [NSString stringWithUTF8String:_dyld_get_image_name(i)]; 38 | *slide = _dyld_get_image_vmaddr_slide(i); 39 | break; 40 | } 41 | } 42 | } 43 | 44 | + (KWCallSite *)callSiteWithCallerAddress:(long)address { 45 | // Symbolicate the address with atos to get the line number & filename. 46 | // If the command raises, no specs will run so don't bother catching 47 | // In the case of a non 0 exit code, failure to launch, or timeout, the 48 | // user will atleast have an idea of why the task failed. 49 | 50 | long slide; 51 | NSString *executablePath; 52 | GetTestBundleExecutablePathSlide(&executablePath, &slide); 53 | NSArray *arguments = @[@"-o", executablePath, @"-s", [NSString stringWithFormat:@"%lx", slide], [NSString stringWithFormat:@"%lx", address]]; 54 | 55 | // See atos man page for more information on arguments. 56 | KWBackgroundTask *symbolicationTask = [[KWBackgroundTask alloc] initWithCommand:@"/usr/bin/atos" arguments:arguments]; 57 | [symbolicationTask launchAndWaitForExit]; 58 | 59 | NSString *symbolicatedCallerAddress = [[NSString alloc] initWithData:symbolicationTask.output encoding:NSUTF8StringEncoding]; 60 | 61 | NSString *pattern = @".+\\((.+):([0-9]+)\\)"; 62 | NSError *error; 63 | NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:NSRegularExpressionCaseInsensitive error:&error]; 64 | NSArray *matches = [regex matchesInString:symbolicatedCallerAddress options:0 range:NSMakeRange(0, symbolicatedCallerAddress.length)]; 65 | 66 | NSString *fileName; 67 | NSInteger lineNumber = 0; 68 | 69 | for (NSTextCheckingResult *ntcr in matches) { 70 | fileName = [symbolicatedCallerAddress substringWithRange:[ntcr rangeAtIndex:1]]; 71 | NSString *lineNumberMatch = [symbolicatedCallerAddress substringWithRange:[ntcr rangeAtIndex:2]]; 72 | lineNumber = lineNumberMatch.integerValue; 73 | } 74 | return [KWCallSite callSiteWithFilename:fileName lineNumber:lineNumber]; 75 | } 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @interface KWValue : NSObject 10 | 11 | #pragma mark - Initializing 12 | 13 | - (id)initWithBytes:(const void *)bytes objCType:(const char *)anObjCType; 14 | 15 | + (id)valueWithBytes:(const void *)bytes objCType:(const char *)anObjCType; 16 | + (id)valueWithBool:(BOOL)aValue; 17 | + (id)valueWithChar:(char)aValue; 18 | + (id)valueWithDouble:(double)aValue; 19 | + (id)valueWithFloat:(float)aValue; 20 | + (id)valueWithInt:(int)aValue; 21 | + (id)valueWithInteger:(NSInteger)aValue; 22 | + (id)valueWithLong:(long)aValue; 23 | + (id)valueWithLongLong:(long long)value; 24 | + (id)valueWithShort:(short)aValue; 25 | + (id)valueWithUnsignedChar:(unsigned char)aValue; 26 | + (id)valueWithUnsignedInt:(unsigned int)aValue; 27 | + (id)valueWithUnsignedInteger:(NSUInteger)aValue; 28 | + (id)valueWithUnsignedLong:(unsigned long)aValue; 29 | + (id)valueWithUnsignedLongLong:(unsigned long long)aValue; 30 | + (id)valueWithUnsignedShort:(unsigned short)aValue; 31 | 32 | #pragma mark - Properties 33 | 34 | @property (nonatomic, readonly) const char *objCType; 35 | @property (nonatomic, readonly) BOOL isNumeric; 36 | 37 | #pragma mark - Accessing Numeric Values 38 | 39 | - (NSNumber *)numberValue; 40 | - (BOOL)boolValue; 41 | - (char)charValue; 42 | - (double)doubleValue; 43 | - (float)floatValue; 44 | - (int)intValue; 45 | - (NSInteger)integerValue; 46 | - (long)longValue; 47 | - (long long)longLongValue; 48 | - (short)shortValue; 49 | - (unsigned char)unsignedCharValue; 50 | - (unsigned int)unsignedIntValue; 51 | - (NSUInteger)unsignedIntegerValue; 52 | - (unsigned long)unsignedLongValue; 53 | - (unsigned long long)unsignedLongLongValue; 54 | - (unsigned short)unsignedShortValue; 55 | 56 | #pragma mark - Accessing Data 57 | 58 | - (NSData *)dataValue; 59 | - (void)getValue:(void *)buffer; 60 | 61 | #pragma mark - Accessing Numeric Data 62 | 63 | - (NSData *)dataForObjCType:(const char *)anObjCType; 64 | - (NSData *)boolData; 65 | - (NSData *)charData; 66 | - (NSData *)doubleData; 67 | - (NSData *)floatData; 68 | - (NSData *)intData; 69 | - (NSData *)integerData; 70 | - (NSData *)longData; 71 | - (NSData *)longLongData; 72 | - (NSData *)shortData; 73 | - (NSData *)unsignedCharData; 74 | - (NSData *)unsignedIntData; 75 | - (NSData *)unsignedIntegerData; 76 | - (NSData *)unsignedLongData; 77 | - (NSData *)unsignedLongLongData; 78 | - (NSData *)unsignedShortData; 79 | 80 | #pragma mark - Comparing Values 81 | 82 | - (NSComparisonResult)compare:(KWValue *)aValue; 83 | 84 | - (BOOL)isEqualToKWValue:(KWValue *)aValue; 85 | - (BOOL)isEqualToNumber:(NSNumber *)aValue; 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWWorkarounds.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | #if KW_TARGET_HAS_INVOCATION_EXCEPTION_BUG 10 | 11 | #pragma mark - Invocation Exception Bug Workaround 12 | 13 | // See KiwiConfiguration.h for notes. 14 | void KWSetExceptionFromAcrossInvocationBoundary(NSException *anException); 15 | NSException *KWGetAndClearExceptionFromAcrossInvocationBoundary(void); 16 | 17 | #endif // #if KW_TARGET_HAS_INVOCATION_EXCEPTION_BUG 18 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KWWorkarounds.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWWorkarounds.h" 8 | 9 | #if KW_TARGET_HAS_INVOCATION_EXCEPTION_BUG 10 | 11 | static NSException *KWExceptionAcrossInvokeBoundary = nil; 12 | 13 | void KWSetExceptionFromAcrossInvocationBoundary(NSException *anException) { 14 | if (KWExceptionAcrossInvokeBoundary != nil) 15 | return; 16 | 17 | KWExceptionAcrossInvokeBoundary = anException; 18 | } 19 | 20 | NSException *KWGetAndClearExceptionFromAcrossInvocationBoundary(void) { 21 | NSException *exception = KWExceptionAcrossInvokeBoundary; 22 | KWExceptionAcrossInvokeBoundary = nil; 23 | return exception; 24 | } 25 | 26 | #endif // #if KW_TARGET_HAS_INVOCATION_EXCEPTION_BUG 27 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KiwiBlockMacros.h: -------------------------------------------------------------------------------- 1 | // 2 | // KiwiBlockMacros.h 3 | // Kiwi 4 | // 5 | // Created by Luke Redpath on 11/07/2011. 6 | // Copyright 2011 Allen Ding. All rights reserved. 7 | // 8 | 9 | // user defined matchers 10 | #define registerMatcher(name) \ 11 | \ 12 | @interface NSObject (KWUserDefinedMatchersDefinitions) \ 13 | - (void)name; \ 14 | @end \ 15 | 16 | #define defineMatcher(...) KWDefineMatchers(__VA_ARGS__) 17 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/KiwiConfiguration.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | // As of iPhone SDK 4 GM, exceptions thrown across an NSInvocation -invoke or 10 | // forwardInvocation: boundary in the simulator will terminate the app instead 11 | // of being caught in @catch blocks from the caller side of the -invoke. Kiwi 12 | // tries to handle this by storing the first exception that it would have 13 | // otherwise thrown in a nasty global that callers can look for and handle. 14 | // (Buggy termination is less desirable than global variables). 15 | // 16 | // Obviously, this can only handles cases where Kiwi itself would have raised 17 | // an exception. 18 | #if TARGET_IPHONE_SIMULATOR 19 | #define KW_TARGET_HAS_INVOCATION_EXCEPTION_BUG 1 20 | #endif 21 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/NSInvocation+KiwiAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @interface NSInvocation(KiwiAdditions) 10 | 11 | #pragma mark - Creating NSInvocation Objects 12 | 13 | + (NSInvocation *)invocationWithTarget:(id)anObject selector:(SEL)aSelector; 14 | + (NSInvocation *)invocationWithTarget:(id)anObject selector:(SEL)aSelector messageArguments:(const void *)firstBytes, ...; 15 | 16 | #pragma mark - Accessing Message Arguments 17 | 18 | // Message arguments are invocation arguments that begin after the target and selector arguments. These methods provide 19 | // convenient ways to access them. 20 | 21 | - (NSData *)messageArgumentDataAtIndex:(NSUInteger)anIndex; 22 | - (void)getMessageArgument:(void *)buffer atIndex:(NSUInteger)anIndex; 23 | - (void)setMessageArgument:(const void *)bytes atIndex:(NSUInteger)anIndex; 24 | - (void)setMessageArguments:(const void *)firstBytes, ...; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/NSInvocation+OCMAdditions.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------------- 2 | // $Id$ 3 | // Copyright (c) 2006-2009 by Mulle Kybernetik. See License file for details. 4 | //--------------------------------------------------------------------------------------- 5 | 6 | #import 7 | 8 | @interface NSInvocation(OCMAdditions) 9 | 10 | - (id)getArgumentAtIndexAsObject:(int)argIndex; 11 | 12 | - (NSString *)invocationDescription; 13 | 14 | - (NSString *)argumentDescriptionAtIndex:(int)argIndex; 15 | 16 | - (NSString *)objectDescriptionAtIndex:(int)anInt; 17 | - (NSString *)charDescriptionAtIndex:(int)anInt; 18 | - (NSString *)unsignedCharDescriptionAtIndex:(int)anInt; 19 | - (NSString *)intDescriptionAtIndex:(int)anInt; 20 | - (NSString *)unsignedIntDescriptionAtIndex:(int)anInt; 21 | - (NSString *)shortDescriptionAtIndex:(int)anInt; 22 | - (NSString *)unsignedShortDescriptionAtIndex:(int)anInt; 23 | - (NSString *)longDescriptionAtIndex:(int)anInt; 24 | - (NSString *)unsignedLongDescriptionAtIndex:(int)anInt; 25 | - (NSString *)longLongDescriptionAtIndex:(int)anInt; 26 | - (NSString *)unsignedLongLongDescriptionAtIndex:(int)anInt; 27 | - (NSString *)doubleDescriptionAtIndex:(int)anInt; 28 | - (NSString *)floatDescriptionAtIndex:(int)anInt; 29 | - (NSString *)structDescriptionAtIndex:(int)anInt; 30 | - (NSString *)pointerDescriptionAtIndex:(int)anInt; 31 | - (NSString *)cStringDescriptionAtIndex:(int)anInt; 32 | - (NSString *)selectorDescriptionAtIndex:(int)anInt; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/NSMethodSignature+KiwiAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @interface NSMethodSignature(KiwiAdditions) 10 | 11 | #pragma mark - Getting Information on Message Arguments 12 | 13 | - (NSUInteger)numberOfMessageArguments; 14 | - (const char *)messageArgumentTypeAtIndex:(NSUInteger)anIndex; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/NSMethodSignature+KiwiAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "NSMethodSignature+KiwiAdditions.h" 8 | 9 | @implementation NSMethodSignature(KiwiAdditions) 10 | 11 | #pragma mark - Getting Information on Message Arguments 12 | 13 | - (NSUInteger)numberOfMessageArguments { 14 | return [self numberOfArguments] - 2; 15 | } 16 | 17 | - (const char *)messageArgumentTypeAtIndex:(NSUInteger)anIndex { 18 | return [self getArgumentTypeAtIndex:anIndex + 2]; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/NSNumber+KiwiAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @interface NSNumber(KiwiAdditions) 10 | 11 | #pragma mark - Creating Numbers 12 | 13 | + (id)numberWithBytes:(const void *)bytes objCType:(const char *)anObjCType; 14 | + (id)numberWithBoolBytes:(const void *)bytes; 15 | + (id)numberWithStdBoolBytes:(const void *)bytes; 16 | + (id)numberWithCharBytes:(const void *)bytes; 17 | + (id)numberWithDoubleBytes:(const void *)bytes; 18 | + (id)numberWithFloatBytes:(const void *)bytes; 19 | + (id)numberWithIntBytes:(const void *)bytes; 20 | + (id)numberWithIntegerBytes:(const void *)bytes; 21 | + (id)numberWithLongBytes:(const void *)bytes; 22 | + (id)numberWithLongLongBytes:(const void *)bytes; 23 | + (id)numberWithShortBytes:(const void *)bytes; 24 | + (id)numberWithUnsignedCharBytes:(const void *)bytes; 25 | + (id)numberWithUnsignedIntBytes:(const void *)bytes; 26 | + (id)numberWithUnsignedIntegerBytes:(const void *)bytes; 27 | + (id)numberWithUnsignedLongBytes:(const void *)bytes; 28 | + (id)numberWithUnsignedLongLongBytes:(const void *)bytes; 29 | + (id)numberWithUnsignedShortBytes:(const void *)bytes; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/NSObject+KiwiSpyAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @class KWCaptureSpy; 10 | 11 | @protocol KiwiSpyAdditions 12 | 13 | - (KWCaptureSpy *)captureArgument:(SEL)selector atIndex:(NSUInteger)index; 14 | + (KWCaptureSpy *)captureArgument:(SEL)selector atIndex:(NSUInteger)index; 15 | 16 | @end 17 | 18 | @interface NSObject (KiwiSpyAdditions) 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/NSObject+KiwiSpyAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "NSObject+KiwiSpyAdditions.h" 8 | 9 | #import "KWCaptureSpy.h" 10 | #import "KWMessagePattern.h" 11 | #import "NSObject+KiwiStubAdditions.h" 12 | 13 | @implementation NSObject (KiwiSpyAdditions) 14 | 15 | - (KWCaptureSpy *)captureArgument:(SEL)selector atIndex:(NSUInteger)index { 16 | KWCaptureSpy *spy = [[KWCaptureSpy alloc] initWithArgumentIndex:index]; 17 | KWMessagePattern *pattern = [[KWMessagePattern alloc] initWithSelector:selector]; 18 | [self addMessageSpy:spy forMessagePattern:pattern]; 19 | return spy; 20 | } 21 | 22 | + (KWCaptureSpy *)captureArgument:(SEL)selector atIndex:(NSUInteger)index { 23 | KWCaptureSpy *spy = [[KWCaptureSpy alloc] initWithArgumentIndex:index]; 24 | KWMessagePattern *pattern = [[KWMessagePattern alloc] initWithSelector:selector]; 25 | [self addMessageSpy:spy forMessagePattern:pattern]; 26 | return spy; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/NSObject+KiwiVerifierAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @protocol KWVerifying; 10 | 11 | @interface NSObject(KiwiVerifierAdditions) 12 | 13 | #pragma mark - Attaching to Verifiers 14 | 15 | - (id)attachToVerifier:(id)aVerifier; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/NSObject+KiwiVerifierAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "NSObject+KiwiVerifierAdditions.h" 8 | #import "KWVerifying.h" 9 | 10 | @implementation NSObject(KiwiVerifierAdditions) 11 | 12 | #pragma mark - Attaching to Verifiers 13 | 14 | - (id)attachToVerifier:(id)aVerifier { 15 | [aVerifier setSubject:self]; 16 | return aVerifier; 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/NSProxy+KiwiVerifierAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2013 Allen Ding. All rights reserved. 5 | // 6 | // Contributed by https://github.com/dwlnetnl 7 | // 8 | 9 | #import "KiwiConfiguration.h" 10 | 11 | @protocol KWVerifying; 12 | 13 | @interface NSProxy (KiwiVerifierAdditions) 14 | 15 | #pragma mark - Attaching to Verifiers 16 | 17 | - (id)attachToVerifier:(id)aVerifier; 18 | - (id)attachToVerifier:(id)firstVerifier verifier:(id)secondVerifier; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/NSProxy+KiwiVerifierAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2013 Allen Ding. All rights reserved. 5 | // 6 | // Contributed by https://github.com/dwlnetnl 7 | // 8 | 9 | #import "NSProxy+KiwiVerifierAdditions.h" 10 | #import "KWVerifying.h" 11 | 12 | @implementation NSProxy (KiwiVerifierAdditions) 13 | 14 | #pragma mark - Attaching to Verifiers 15 | 16 | - (id)attachToVerifier:(id)aVerifier { 17 | [aVerifier setSubject:self]; 18 | return aVerifier; 19 | } 20 | 21 | - (id)attachToVerifier:(id)firstVerifier verifier:(id)secondVerifier { 22 | [firstVerifier setSubject:self]; 23 | [secondVerifier setSubject:self]; 24 | return firstVerifier; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/NSValue+KiwiAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @interface NSValue(KiwiAdditions) 10 | 11 | #pragma mark - Accessing Data 12 | 13 | - (NSData *)dataValue; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Core/NSValue+KiwiAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "NSValue+KiwiAdditions.h" 8 | #import "KWObjCUtilities.h" 9 | 10 | @implementation NSValue(KiwiAdditions) 11 | 12 | #pragma mark - Accessing Data 13 | 14 | - (NSData *)dataValue { 15 | NSUInteger length = KWObjCTypeLength([self objCType]); 16 | void *buffer = malloc(length); 17 | [self getValue:buffer]; 18 | NSData *data = [NSData dataWithBytes:buffer length:length]; 19 | free(buffer); 20 | return data; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeBetweenMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | 10 | @interface KWBeBetweenMatcher : KWMatcher 11 | 12 | #pragma mark - Configuring Matchers 13 | 14 | // TODO: 'and' below is a reserved word in C++ 15 | - (void)beBetween:(id)aLowerEndpoint and:(id)anUpperEndpoint; 16 | - (void)beInTheIntervalFrom:(id)aLowerEndpoint to:(id)anUpperEndpoint; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeBetweenMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWBeBetweenMatcher.h" 8 | #import "KWFormatter.h" 9 | 10 | @interface KWBeBetweenMatcher() 11 | 12 | #pragma mark - Properties 13 | 14 | @property (nonatomic, strong) id lowerEndpoint; 15 | @property (nonatomic, strong) id upperEndpoint; 16 | 17 | @end 18 | 19 | @implementation KWBeBetweenMatcher 20 | 21 | #pragma mark - Getting Matcher Strings 22 | 23 | + (NSArray *)matcherStrings { 24 | return @[@"beBetween:and:", @"beInTheIntervalFrom:to:"]; 25 | } 26 | 27 | #pragma mark - Matching 28 | 29 | - (BOOL)evaluate { 30 | if (![self.subject respondsToSelector:@selector(compare:)]) 31 | [NSException raise:@"KWMatcherException" format:@"subject does not respond to -compare:"]; 32 | 33 | NSComparisonResult lowerResult = [self.subject compare:self.lowerEndpoint]; 34 | NSComparisonResult upperResult = [self.subject compare:self.upperEndpoint]; 35 | return (lowerResult == NSOrderedDescending || lowerResult == NSOrderedSame) && 36 | (upperResult == NSOrderedAscending || upperResult == NSOrderedSame); 37 | } 38 | 39 | #pragma mark - Getting Failure Messages 40 | 41 | - (NSString *)failureMessageForShould { 42 | return [NSString stringWithFormat:@"expected subject to be in the interval [%@, %@], got %@", 43 | [KWFormatter formatObject:self.lowerEndpoint], 44 | [KWFormatter formatObject:self.upperEndpoint], 45 | [KWFormatter formatObject:self.subject]]; 46 | } 47 | 48 | - (NSString *)description { 49 | return [NSString stringWithFormat:@"be between %@ and %@", self.lowerEndpoint, self.upperEndpoint]; 50 | } 51 | 52 | #pragma mark - Configuring Matchers 53 | 54 | - (void)beBetween:(id)aLowerEndpoint and:(id)anUpperEndpoint { 55 | [self beInTheIntervalFrom:aLowerEndpoint to:anUpperEndpoint]; 56 | } 57 | 58 | - (void)beInTheIntervalFrom:(id)aLowerEndpoint to:(id)anUpperEndpoint { 59 | self.lowerEndpoint = aLowerEndpoint; 60 | self.upperEndpoint = anUpperEndpoint; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeEmptyMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | 10 | @interface KWBeEmptyMatcher : KWMatcher 11 | 12 | #pragma mark - Configuring Matchers 13 | 14 | - (void)beEmpty; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeEmptyMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWBeEmptyMatcher.h" 8 | #import "KWFormatter.h" 9 | 10 | @interface KWBeEmptyMatcher() 11 | 12 | #pragma mark - Properties 13 | 14 | @property (nonatomic, readwrite) NSUInteger count; 15 | 16 | @end 17 | 18 | @implementation KWBeEmptyMatcher 19 | 20 | #pragma mark - Getting Matcher Strings 21 | 22 | + (NSArray *)matcherStrings { 23 | return @[@"beEmpty"]; 24 | } 25 | 26 | #pragma mark - Matching 27 | 28 | - (BOOL)evaluate { 29 | if ([self.subject respondsToSelector:@selector(count)]) { 30 | self.count = [self.subject count]; 31 | return self.count == 0; 32 | } 33 | else if ([self.subject respondsToSelector:@selector(length)]) { 34 | self.count = [self.subject length]; 35 | return self.count == 0; 36 | } 37 | 38 | [NSException raise:@"KWMatcherException" format:@"subject does not respond to -count or -length"]; 39 | return NO; 40 | } 41 | 42 | #pragma mark - Getting Failure Messages 43 | 44 | - (NSString *)countPhrase { 45 | if (self.count == 1) 46 | return @"1 item"; 47 | else 48 | return [NSString stringWithFormat:@"%u items", (unsigned)self.count]; 49 | } 50 | 51 | - (NSString *)failureMessageForShould { 52 | return [NSString stringWithFormat:@"expected subject to be empty, got %@", [self countPhrase]]; 53 | } 54 | 55 | - (NSString *)failureMessageForShouldNot { 56 | return @"expected subject not to be empty"; 57 | } 58 | 59 | - (NSString *)description { 60 | return @"be empty"; 61 | } 62 | 63 | #pragma mark - Configuring Matchers 64 | 65 | - (void)beEmpty { 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeIdenticalToMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | 10 | @interface KWBeIdenticalToMatcher : KWMatcher 11 | 12 | #pragma mark - Configuring Matchers 13 | 14 | - (void)beIdenticalTo:(id)anObject; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeIdenticalToMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWBeIdenticalToMatcher.h" 8 | #import "KWFormatter.h" 9 | 10 | @interface KWBeIdenticalToMatcher() 11 | 12 | #pragma mark - Properties 13 | 14 | @property (nonatomic, readwrite, strong) id otherSubject; 15 | 16 | @end 17 | 18 | @implementation KWBeIdenticalToMatcher 19 | 20 | #pragma mark - Getting Matcher Strings 21 | 22 | + (NSArray *)matcherStrings { 23 | return @[@"beIdenticalTo:"]; 24 | } 25 | 26 | #pragma mark - Matching 27 | 28 | - (BOOL)evaluate { 29 | return self.subject == self.otherSubject; 30 | } 31 | 32 | #pragma mark - Getting Failure Messages 33 | 34 | - (NSString *)failureMessageForShould { 35 | return [NSString stringWithFormat:@"expected subject to be identical to %@ (%p), got %@ (%p)", 36 | [KWFormatter formatObject:self.otherSubject], 37 | self.otherSubject, 38 | [KWFormatter formatObject:self.subject], 39 | self.subject]; 40 | } 41 | 42 | - (NSString *)failureMessageForShouldNot { 43 | return [NSString stringWithFormat:@"expected subject not to be identical to %@ (%p)", 44 | [KWFormatter formatObject:self.otherSubject], 45 | self.otherSubject]; 46 | } 47 | 48 | - (NSString *)description { 49 | return [NSString stringWithFormat:@"be identical to %@", self.otherSubject]; 50 | } 51 | 52 | #pragma mark - Configuring Matchers 53 | 54 | - (void)beIdenticalTo:(id)anObject { 55 | self.otherSubject = anObject; 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeKindOfClassMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | 10 | @interface KWBeKindOfClassMatcher : KWMatcher 11 | 12 | #pragma mark - Configuring Matchers 13 | 14 | - (void)beKindOfClass:(Class)aClass; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeKindOfClassMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWBeKindOfClassMatcher.h" 8 | #import "KWFormatter.h" 9 | 10 | @interface KWBeKindOfClassMatcher() 11 | 12 | @property (nonatomic, assign) Class targetClass; 13 | 14 | @end 15 | 16 | @implementation KWBeKindOfClassMatcher 17 | 18 | #pragma mark - Getting Matcher Strings 19 | 20 | + (NSArray *)matcherStrings { 21 | return @[@"beKindOfClass:"]; 22 | } 23 | 24 | #pragma mark - Matching 25 | 26 | - (BOOL)evaluate { 27 | return [self.subject isKindOfClass:self.targetClass]; 28 | } 29 | 30 | #pragma mark - Getting Failure Messages 31 | 32 | - (NSString *)failureMessageForShould { 33 | return [NSString stringWithFormat:@"expected subject to be kind of %@, got %@", 34 | NSStringFromClass(self.targetClass), 35 | NSStringFromClass([self.subject class])]; 36 | } 37 | 38 | - (NSString *)description { 39 | return [NSString stringWithFormat:@"be kind of %@", NSStringFromClass(self.targetClass)]; 40 | } 41 | 42 | #pragma mark - Configuring Matchers 43 | 44 | - (void)beKindOfClass:(Class)aClass { 45 | self.targetClass = aClass; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeMemberOfClassMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | 10 | @interface KWBeMemberOfClassMatcher : KWMatcher 11 | 12 | #pragma mark - Configuring Matchers 13 | 14 | - (void)beMemberOfClass:(Class)aClass; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeMemberOfClassMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWBeMemberOfClassMatcher.h" 8 | #import "KWFormatter.h" 9 | 10 | @interface KWBeMemberOfClassMatcher() 11 | 12 | @property (nonatomic, assign) Class targetClass; 13 | 14 | @end 15 | 16 | @implementation KWBeMemberOfClassMatcher 17 | 18 | #pragma mark - Getting Matcher Strings 19 | 20 | + (NSArray *)matcherStrings { 21 | return @[@"beMemberOfClass:"]; 22 | } 23 | 24 | #pragma mark - Matching 25 | 26 | - (BOOL)evaluate { 27 | return [self.subject isMemberOfClass:self.targetClass]; 28 | } 29 | 30 | #pragma mark - Getting Failure Messages 31 | 32 | - (NSString *)failureMessageForShould { 33 | return [NSString stringWithFormat:@"expected subject to be member of %@, got %@", 34 | NSStringFromClass(self.targetClass), 35 | NSStringFromClass([self.subject class])]; 36 | } 37 | 38 | - (NSString *)description { 39 | return [NSString stringWithFormat:@"be member of %@", 40 | NSStringFromClass(self.targetClass)]; 41 | } 42 | 43 | #pragma mark - Configuring Matchers 44 | 45 | - (void)beMemberOfClass:(Class)aClass { 46 | self.targetClass = aClass; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeSubclassOfClassMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | 10 | @interface KWBeSubclassOfClassMatcher : KWMatcher 11 | 12 | #pragma mark - Configuring Matchers 13 | 14 | - (void)beSubclassOfClass:(Class)aClass; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeSubclassOfClassMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWBeSubclassOfClassMatcher.h" 8 | #import "KWFormatter.h" 9 | 10 | @interface KWBeSubclassOfClassMatcher() 11 | 12 | #pragma mark - Properties 13 | 14 | @property (nonatomic, assign) Class targetClass; 15 | 16 | @end 17 | 18 | @implementation KWBeSubclassOfClassMatcher 19 | 20 | #pragma mark - Getting Matcher Strings 21 | 22 | + (NSArray *)matcherStrings { 23 | return @[@"beSubclassOfClass:"]; 24 | } 25 | 26 | #pragma mark - Matching 27 | 28 | - (BOOL)evaluate { 29 | return [self.subject isSubclassOfClass:self.targetClass]; 30 | } 31 | 32 | #pragma mark - Getting Failure Messages 33 | 34 | - (NSString *)failureMessageForShould { 35 | return [NSString stringWithFormat:@"expected subject to be subclass of %@, got %@", 36 | NSStringFromClass(self.targetClass), 37 | NSStringFromClass([self.subject class])]; 38 | } 39 | 40 | - (NSString *)description { 41 | return [NSString stringWithFormat:@"be subclass of %@", 42 | NSStringFromClass(self.targetClass)]; 43 | } 44 | 45 | #pragma mark - Configuring Matchers 46 | 47 | - (void)beSubclassOfClass:(Class)aClass { 48 | self.targetClass = aClass; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeTrueMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | 10 | @interface KWBeTrueMatcher : KWMatcher 11 | 12 | #pragma mark - Configuring Matchers 13 | 14 | - (void)beTrue; 15 | - (void)beFalse; 16 | - (void)beYes; 17 | - (void)beNo; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeTrueMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWBeTrueMatcher.h" 8 | 9 | @interface KWBeTrueMatcher() 10 | 11 | @property (nonatomic, readwrite) BOOL expectedValue; 12 | 13 | @end 14 | 15 | @implementation KWBeTrueMatcher 16 | 17 | #pragma mark - Getting Matcher Strings 18 | 19 | + (NSArray *)matcherStrings { 20 | return @[@"beTrue", @"beFalse", @"beYes", @"beNo"]; 21 | } 22 | 23 | #pragma mark - Matching 24 | 25 | - (BOOL)evaluate { 26 | if (![self.subject respondsToSelector:@selector(boolValue)]) 27 | [NSException raise:@"KWMatcherException" format:@"subject does not respond to -boolValue"]; 28 | 29 | return [self.subject boolValue] == self.expectedValue; 30 | } 31 | 32 | #pragma mark - Getting Failure Messages 33 | 34 | - (NSString *)failureMessageForShould { 35 | return [NSString stringWithFormat:@"expected subject to be %@", 36 | self.expectedValue ? @"true" : @"false"]; 37 | } 38 | 39 | - (NSString *)description { 40 | if (self.expectedValue == YES) { 41 | return @"be true"; 42 | } 43 | return @"be false"; 44 | } 45 | 46 | #pragma mark - Configuring Matchers 47 | 48 | - (void)beTrue { 49 | self.expectedValue = YES; 50 | } 51 | 52 | - (void)beFalse { 53 | self.expectedValue = NO; 54 | } 55 | 56 | - (void)beYes { 57 | self.expectedValue = YES; 58 | } 59 | 60 | - (void)beNo { 61 | self.expectedValue = NO; 62 | } 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeWithinMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | 10 | @interface KWBeWithinMatcher : KWMatcher 11 | 12 | #pragma mark - Configuring Matchers 13 | 14 | - (void)beWithin:(id)aDistance of:(id)aValue; 15 | - (void)equal:(double)aValue withDelta:(double)aDelta; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeWithinMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWBeWithinMatcher.h" 8 | #import "KWFormatter.h" 9 | #import "KWObjCUtilities.h" 10 | #import "KWValue.h" 11 | 12 | @interface KWBeWithinMatcher() 13 | 14 | @property (nonatomic, readwrite, strong) id distance; 15 | @property (nonatomic, readwrite, strong) id otherValue; 16 | 17 | @end 18 | 19 | @implementation KWBeWithinMatcher 20 | 21 | #pragma mark - Getting Matcher Strings 22 | 23 | + (NSArray *)matcherStrings { 24 | return @[@"beWithin:of:", @"equal:withDelta:"]; 25 | } 26 | 27 | #pragma mark - Matching 28 | 29 | // Evaluation is done by getting the underlying values as the widest data 30 | // types available. 31 | 32 | - (BOOL)evaluateForFloatingPoint { 33 | double firstValue = [self.subject doubleValue]; 34 | double secondValue = [self.otherValue doubleValue]; 35 | double theDistance = [self.distance doubleValue]; 36 | double absoluteDifference = firstValue > secondValue ? firstValue - secondValue : secondValue - firstValue; 37 | return absoluteDifference <= theDistance; 38 | } 39 | 40 | - (BOOL)evaluateForUnsignedIntegral { 41 | unsigned long long firstValue = [self.subject unsignedLongLongValue]; 42 | unsigned long long secondValue = [self.otherValue unsignedLongLongValue]; 43 | unsigned long long theDistance = [self.distance unsignedLongLongValue]; 44 | unsigned long long absoluteDifference = firstValue > secondValue ? firstValue - secondValue : secondValue - firstValue; 45 | return absoluteDifference <= theDistance; 46 | } 47 | 48 | - (BOOL)evaluateForSignedIntegral { 49 | long long firstValue = [self.subject longLongValue]; 50 | long long secondValue = [self.otherValue longLongValue]; 51 | long long theDistance = [self.distance longLongValue]; 52 | long long absoluteDifference = firstValue > secondValue ? firstValue - secondValue : secondValue - firstValue; 53 | return absoluteDifference <= theDistance; 54 | } 55 | 56 | - (BOOL)evaluate { 57 | const char *objCType = [self.subject objCType]; 58 | 59 | if (KWObjCTypeIsFloatingPoint(objCType)) 60 | return [self evaluateForFloatingPoint]; 61 | else if (KWObjCTypeIsUnsignedIntegral(objCType)) 62 | return [self evaluateForUnsignedIntegral]; 63 | else 64 | return [self evaluateForSignedIntegral]; 65 | } 66 | 67 | #pragma mark - Getting Failure Messages 68 | 69 | - (NSString *)failureMessageForShould { 70 | return [NSString stringWithFormat:@"expected subject to be within %@ of %@, got %@", 71 | [KWFormatter formatObject:self.distance], 72 | [KWFormatter formatObject:self.otherValue], 73 | [KWFormatter formatObject:self.subject]]; 74 | } 75 | 76 | - (NSString *)description { 77 | return [NSString stringWithFormat:@"be within %@ of %@", self.distance, self.otherValue]; 78 | } 79 | 80 | #pragma mark - Configuring Matchers 81 | 82 | - (void)beWithin:(id)aDistance of:(id)aValue { 83 | self.distance = aDistance; 84 | self.otherValue = aValue; 85 | } 86 | 87 | - (void)equal:(double)aValue withDelta:(double)aDelta { 88 | [self beWithin:[KWValue valueWithDouble:aDelta] of:[KWValue valueWithDouble:aValue]]; 89 | } 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeZeroMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | 10 | @interface KWBeZeroMatcher : KWMatcher 11 | 12 | #pragma mark - Configuring Matchers 13 | 14 | - (void)beZero; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBeZeroMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWBeZeroMatcher.h" 8 | #import "KWFormatter.h" 9 | #import "KWValue.h" 10 | 11 | @implementation KWBeZeroMatcher 12 | 13 | #pragma mark - Getting Matcher Strings 14 | 15 | + (NSArray *)matcherStrings { 16 | return @[@"beZero"]; 17 | } 18 | 19 | #pragma mark - Matching 20 | 21 | - (BOOL)evaluate { 22 | if ([self.subject isKindOfClass:[NSNumber class]]) { 23 | return [self.subject isEqualToNumber:@0]; 24 | } 25 | 26 | if ([self.subject respondsToSelector:@selector(numberValue)]) { 27 | return [[self.subject numberValue] isEqualToNumber:@0]; 28 | } 29 | 30 | return NO; 31 | } 32 | 33 | #pragma mark - Getting Failure Messages 34 | 35 | - (NSString *)failureMessageForShould { 36 | return [NSString stringWithFormat:@"expected subject to be zero, got %@", 37 | [KWFormatter formatObject:self.subject]]; 38 | } 39 | 40 | - (NSString *)failureMessageForShouldNot { 41 | return [NSString stringWithFormat:@"expected subject not to be zero"]; 42 | } 43 | 44 | - (NSString *)description { 45 | return @"be zero"; 46 | } 47 | 48 | #pragma mark - Configuring Matchers 49 | 50 | - (void)beZero { 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBlockRaiseMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | 10 | @interface KWBlockRaiseMatcher : KWMatcher 11 | 12 | #pragma mark - Configuring Matchers 13 | 14 | - (void)raise; 15 | - (void)raiseWithName:(NSString *)aName; 16 | - (void)raiseWithReason:(NSString *)aReason; 17 | - (void)raiseWithName:(NSString *)aName reason:(NSString *)aReason; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWBlockRaiseMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWBlockRaiseMatcher.h" 8 | #import "KWBlock.h" 9 | 10 | @interface KWBlockRaiseMatcher() 11 | 12 | @property (nonatomic, readwrite, strong) NSException *exception; 13 | @property (nonatomic, readwrite, strong) NSException *actualException; 14 | 15 | @end 16 | 17 | @implementation KWBlockRaiseMatcher 18 | 19 | #pragma mark - Getting Matcher Strings 20 | 21 | + (NSArray *)matcherStrings { 22 | return @[@"raise", 23 | @"raiseWithName:", 24 | @"raiseWithReason:", 25 | @"raiseWithName:reason:"]; 26 | } 27 | 28 | #pragma mark - Matching 29 | 30 | - (BOOL)evaluate { 31 | if (![self.subject isKindOfClass:[KWBlock class]]) 32 | [NSException raise:@"KWMatcherException" format:@"subject must be a KWBlock"]; 33 | 34 | @try { 35 | [self.subject call]; 36 | } @catch (NSException *anException) { 37 | self.actualException = anException; 38 | 39 | if ([self.exception name] != nil && ![[self.exception name] isEqualToString:[anException name]]) 40 | return NO; 41 | 42 | if ([self.exception reason] != nil && ![[self.exception reason] isEqualToString:[anException reason]]) 43 | return NO; 44 | 45 | return YES; 46 | } 47 | 48 | return NO; 49 | } 50 | 51 | #pragma mark - Getting Failure Messages 52 | 53 | + (NSString *)exceptionPhraseWithException:(NSException *)anException { 54 | if (anException == nil) 55 | return @"nothing"; 56 | 57 | NSString *namePhrase = nil; 58 | 59 | if ([anException name] == nil) 60 | namePhrase = @"exception"; 61 | else 62 | namePhrase = [anException name]; 63 | 64 | if ([anException reason] == nil) 65 | return namePhrase; 66 | 67 | return [NSString stringWithFormat:@"%@ \"%@\"", namePhrase, [anException reason]]; 68 | } 69 | 70 | - (NSString *)failureMessageForShould { 71 | return [NSString stringWithFormat:@"expected %@, but %@ raised", 72 | [[self class] exceptionPhraseWithException:self.exception], 73 | [[self class] exceptionPhraseWithException:self.actualException]]; 74 | } 75 | 76 | - (NSString *)failureMessageForShouldNot { 77 | return [NSString stringWithFormat:@"expected %@ not to be raised", 78 | [[self class] exceptionPhraseWithException:self.actualException]]; 79 | } 80 | 81 | #pragma mark - Configuring Matchers 82 | 83 | - (void)raise { 84 | [self raiseWithName:nil reason:nil]; 85 | } 86 | 87 | - (void)raiseWithName:(NSString *)aName { 88 | [self raiseWithName:aName reason:nil]; 89 | } 90 | 91 | - (void)raiseWithReason:(NSString *)aReason { 92 | [self raiseWithName:nil reason:aReason]; 93 | } 94 | 95 | - (void)raiseWithName:(NSString *)aName reason:(NSString *)aReason { 96 | self.exception = [NSException exceptionWithName:aName reason:aReason userInfo:nil]; 97 | } 98 | 99 | - (NSString *)description { 100 | return [NSString stringWithFormat:@"raise %@", [[self class] exceptionPhraseWithException:self.exception]]; 101 | } 102 | 103 | @end 104 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWChangeMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWChangeMatcher.h 3 | // Kiwi 4 | // 5 | // Copyright (c) 2013 Eloy Durán . 6 | // All rights reserved. 7 | // 8 | 9 | #import "KWMatcher.h" 10 | 11 | typedef NSInteger (^KWChangeMatcherCountBlock)(void); 12 | 13 | @interface KWChangeMatcher : KWMatcher 14 | 15 | // Expect _any_ change. 16 | - (void)change:(KWChangeMatcherCountBlock)countBlock; 17 | 18 | // Expect changes by a specific amount. 19 | - (void)change:(KWChangeMatcherCountBlock)countBlock by:(NSInteger)expectedDifference; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWChangeMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // KWChangeMatcher.m 3 | // Kiwi 4 | // 5 | // Copyright (c) 2013 Eloy Durán . 6 | // All rights reserved. 7 | // 8 | 9 | #import "KWChangeMatcher.h" 10 | #import "KWBlock.h" 11 | 12 | @interface KWChangeMatcher () 13 | @property (nonatomic, copy) KWChangeMatcherCountBlock countBlock; 14 | @property (nonatomic, assign) BOOL anyChange; 15 | @property (nonatomic, assign) NSInteger expectedDifference, expectedTotal, actualTotal; 16 | @end 17 | 18 | @implementation KWChangeMatcher 19 | 20 | + (NSArray *)matcherStrings { 21 | return @[@"change:by:", @"change:"]; 22 | } 23 | 24 | - (NSString *)failureMessageForShould { 25 | if (self.anyChange) { 26 | return @"expected subject to change the count"; 27 | } else { 28 | return [NSString stringWithFormat:@"expected subject to change the count to %d, got %d", (int)self.expectedTotal, (int)self.actualTotal]; 29 | } 30 | } 31 | 32 | - (NSString *)failureMessageForShouldNot { 33 | if (self.anyChange) { 34 | return @"expected subject to not change the count"; 35 | } else { 36 | return [NSString stringWithFormat:@"expected subject not to change the count to %d", (int)self.actualTotal]; 37 | } 38 | } 39 | 40 | - (NSString *)description { 41 | if (self.anyChange) { 42 | return @"change count"; 43 | } else { 44 | return [NSString stringWithFormat:@"change count by %d", (int)self.expectedDifference]; 45 | } 46 | } 47 | 48 | - (BOOL)evaluate { 49 | NSInteger before = self.countBlock(); 50 | // Perform actual work, which is expected to change the result of countBlock. 51 | [self.subject call]; 52 | self.actualTotal = self.countBlock(); 53 | 54 | if (self.anyChange) { 55 | return before != self.actualTotal; 56 | } else { 57 | self.expectedTotal = before + self.expectedDifference; 58 | return self.expectedTotal == self.actualTotal; 59 | } 60 | } 61 | 62 | - (void)change:(KWChangeMatcherCountBlock)countBlock by:(NSInteger)expectedDifference { 63 | self.anyChange = NO; 64 | self.expectedDifference = expectedDifference; 65 | self.countBlock = countBlock; 66 | } 67 | 68 | - (void)change:(KWChangeMatcherCountBlock)countBlock { 69 | self.anyChange = YES; 70 | self.countBlock = countBlock; 71 | } 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWConformToProtocolMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | 10 | @interface KWConformToProtocolMatcher : KWMatcher 11 | 12 | #pragma mark - Configuring Matchers 13 | 14 | - (void)conformToProtocol:(Protocol *)aProtocol; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWConformToProtocolMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWConformToProtocolMatcher.h" 8 | #import "KWFormatter.h" 9 | 10 | @interface KWConformToProtocolMatcher() 11 | 12 | @property (nonatomic, assign) Protocol *protocol; 13 | 14 | @end 15 | 16 | @implementation KWConformToProtocolMatcher 17 | 18 | #pragma mark - Getting Matcher Strings 19 | 20 | + (NSArray *)matcherStrings { 21 | return @[@"conformToProtocol:"]; 22 | } 23 | 24 | #pragma mark - Matching 25 | 26 | - (BOOL)evaluate { 27 | return [self.subject conformsToProtocol:self.protocol]; 28 | } 29 | 30 | #pragma mark - Getting Failure Messages 31 | 32 | - (NSString *)failureMessageForShould { 33 | return [NSString stringWithFormat:@"expected subject to conform to %@ protocol", 34 | NSStringFromProtocol(self.protocol)]; 35 | } 36 | 37 | - (NSString *)description { 38 | return [NSString stringWithFormat:@"conform to %@ protocol", NSStringFromProtocol(self.protocol)]; 39 | } 40 | 41 | #pragma mark - Configuring Matchers 42 | 43 | - (void)conformToProtocol:(Protocol *)aProtocol { 44 | self.protocol = aProtocol; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWContainMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | #import "KWMatchVerifier.h" 10 | 11 | @interface KWContainMatcher : KWMatcher 12 | 13 | #pragma mark - Configuring Matchers 14 | 15 | - (void)contain:(id)anObject; 16 | - (void)containObjectsInArray:(NSArray *)anArray; 17 | 18 | @end 19 | 20 | @interface KWMatchVerifier(KWContainMatcherAdditions) 21 | 22 | #pragma mark - Verifying 23 | 24 | - (void)containObjects:(id)firstObject, ... NS_REQUIRES_NIL_TERMINATION; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWContainMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWContainMatcher.h" 8 | #import "KWFormatter.h" 9 | #import "KWGenericMatchingAdditions.h" 10 | 11 | @interface KWContainMatcher() 12 | 13 | @property (nonatomic, readwrite, strong) id objects; 14 | 15 | @end 16 | 17 | @implementation KWContainMatcher 18 | 19 | #pragma mark - Getting Matcher Strings 20 | 21 | + (NSArray *)matcherStrings { 22 | return @[@"contain:", @"containObjectsInArray:"]; 23 | } 24 | 25 | #pragma mark - Matching 26 | 27 | - (BOOL)evaluate { 28 | if (![self.subject respondsToSelector:@selector(containsObjectEqualToOrMatching:)]) 29 | [NSException raise:@"KWMatcherException" format:@"subject does not respond to -containsObjectEqualToOrMatching:"]; 30 | 31 | for (id object in self.objects) { 32 | if (![self.subject containsObjectEqualToOrMatching:object]) 33 | return NO; 34 | } 35 | 36 | return YES; 37 | } 38 | 39 | #pragma mark - Getting Failure Messages 40 | 41 | - (NSString *)objectsPhrase { 42 | if ([self.objects count] == 1) 43 | return [KWFormatter formatObject:(self.objects)[0]]; 44 | 45 | return [NSString stringWithFormat:@"all of %@", [KWFormatter formatObject:self.objects]]; 46 | } 47 | 48 | - (NSString *)failureMessageForShould { 49 | return [NSString stringWithFormat:@"expected subject to contain %@", [self objectsPhrase]]; 50 | } 51 | 52 | - (NSString *)description { 53 | return [NSString stringWithFormat:@"contain %@", [self objectsPhrase]]; 54 | } 55 | 56 | #pragma mark - Configuring Matchers 57 | 58 | - (void)contain:(id)anObject { 59 | self.objects = @[anObject]; 60 | } 61 | 62 | - (void)containObjectsInArray:(NSArray *)anArray { 63 | self.objects = anArray; 64 | } 65 | 66 | @end 67 | 68 | @implementation KWMatchVerifier(KWContainMatcherAdditions) 69 | 70 | #pragma mark - Verifying 71 | 72 | - (void)containObjects:(id)firstObject, ... { 73 | NSMutableArray *objects = [NSMutableArray array]; 74 | 75 | va_list argumentList; 76 | va_start(argumentList, firstObject); 77 | id object = firstObject; 78 | 79 | while (object != nil) { 80 | [objects addObject:object]; 81 | object = va_arg(argumentList, id); 82 | } 83 | 84 | va_end(argumentList); 85 | [(id)self containObjectsInArray:objects]; 86 | } 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWContainStringMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWContainStringMatcher.h 3 | // Kiwi 4 | // 5 | // Created by Kristopher Johnson on 4/28/13. 6 | // Copyright (c) 2013 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import "KiwiConfiguration.h" 10 | #import "KWMatcher.h" 11 | 12 | // Kiwi matcher for determining whether a string contains an expected substring 13 | // 14 | // Examples: 15 | // 16 | // [[@"Hello, world!" should] containString:@"world"]; 17 | // [[@"Hello, world!" shouldNot] containString:@"xyzzy"]; 18 | // 19 | // [[@"Hello, world!" should] containString:@"WORLD" 20 | // options:NSCaseInsensitiveSearch]; 21 | // 22 | // [[@"Hello, world!" should] startWithString:@"Hello,"]; 23 | // [[@"Hello, world!" should] endWithString:@"world!"]; 24 | 25 | @interface KWContainStringMatcher : KWMatcher 26 | 27 | // Match if subject contains specified substring 28 | - (void)containString:(NSString *)string; 29 | 30 | // Match if subject contains specified substring, using specified comparison options 31 | - (void)containString:(NSString *)string options:(NSStringCompareOptions)options; 32 | 33 | // Match if subject starts with the specified prefix 34 | - (void)startWithString:(NSString *)prefix; 35 | 36 | // Match if subject ends with the specified prefix 37 | - (void)endWithString:(NSString *)suffix; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWContainStringMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // KWContainStringMatcher.m 3 | // Kiwi 4 | // 5 | // Created by Kristopher Johnson on 4/28/13. 6 | // Copyright (c) 2013 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import "KWContainStringMatcher.h" 10 | #import "KWFormatter.h" 11 | 12 | @interface KWContainStringMatcher () 13 | 14 | @property (nonatomic, copy) NSString *substring; 15 | @property (nonatomic) NSStringCompareOptions options; 16 | 17 | @end 18 | 19 | 20 | @implementation KWContainStringMatcher 21 | 22 | #pragma mark - Getting Matcher Strings 23 | 24 | + (NSArray *)matcherStrings { 25 | return @[@"containString:", 26 | @"containString:options:", 27 | @"startWithString:", 28 | @"endWithString:"]; 29 | } 30 | 31 | #pragma mark - Matching 32 | 33 | - (BOOL)evaluate { 34 | NSString *subjectString = (NSString *)self.subject; 35 | if (![subjectString isKindOfClass:[NSString class]]) { 36 | [NSException raise:@"KWMatcherException" format:@"subject is not a string"]; 37 | return NO; 38 | } 39 | 40 | NSRange range = [subjectString rangeOfString:self.substring options:self.options]; 41 | return (range.location != NSNotFound); 42 | } 43 | 44 | #pragma mark - Getting Failure Messages 45 | 46 | - (NSString *)failureMessageForShould { 47 | return [NSString stringWithFormat:@"%@ did not contain string \"%@\"", 48 | [KWFormatter formatObject:self.subject], 49 | self.substring]; 50 | } 51 | 52 | - (NSString *)failureMessageForShouldNot { 53 | return [NSString stringWithFormat:@"expected subject not to contain string \"%@\"", 54 | self.substring]; 55 | } 56 | 57 | - (NSString *)description { 58 | return [NSString stringWithFormat:@"contain substring \"%@\"", self.substring]; 59 | } 60 | 61 | #pragma mark - Configuring matchers 62 | 63 | - (void)containString:(NSString *)substring { 64 | self.substring = substring; 65 | self.options = 0; 66 | } 67 | 68 | - (void)containString:(NSString *)substring options:(NSStringCompareOptions)options { 69 | self.substring = substring; 70 | self.options = options; 71 | } 72 | 73 | - (void)startWithString:(NSString *)prefix { 74 | self.substring = prefix; 75 | self.options = NSAnchoredSearch; 76 | } 77 | 78 | - (void)endWithString:(NSString *)suffix { 79 | self.substring = suffix; 80 | self.options = NSAnchoredSearch | NSBackwardsSearch; 81 | } 82 | 83 | @end 84 | 85 | 86 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWEqualMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | 10 | @interface KWEqualMatcher : KWMatcher 11 | 12 | #pragma mark - Configuring Matchers 13 | 14 | - (void)equal:(id)anObject; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWEqualMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWEqualMatcher.h" 8 | #import "KWFormatter.h" 9 | #import "KWValue.h" 10 | 11 | @interface KWEqualMatcher() 12 | 13 | #pragma mark - Properties 14 | 15 | @property (nonatomic, readwrite, strong) id otherSubject; 16 | 17 | @end 18 | 19 | @implementation KWEqualMatcher 20 | 21 | #pragma mark - Initializing 22 | 23 | 24 | #pragma mark - Properties 25 | 26 | @synthesize otherSubject; 27 | 28 | #pragma mark - Getting Matcher Strings 29 | 30 | + (NSArray *)matcherStrings { 31 | return @[@"equal:"]; 32 | } 33 | 34 | #pragma mark - Matching 35 | 36 | - (BOOL)evaluate { 37 | /** handle this as a special case; KWValue supports NSNumber equality but not vice-versa **/ 38 | if ([self.subject isKindOfClass:[NSNumber class]] && [self.otherSubject isKindOfClass:[KWValue class]]) { 39 | return [self.otherSubject isEqual:self.subject]; 40 | } 41 | return [self.subject isEqual:self.otherSubject]; 42 | } 43 | 44 | #pragma mark - Getting Failure Messages 45 | 46 | - (NSString *)failureMessageForShould { 47 | return [NSString stringWithFormat:@"expected subject to equal %@, got %@", 48 | [KWFormatter formatObjectIncludingClass:self.otherSubject], 49 | [KWFormatter formatObjectIncludingClass:self.subject]]; 50 | } 51 | 52 | - (NSString *)failureMessageForShouldNot { 53 | return [NSString stringWithFormat:@"expected subject not to equal %@", 54 | [KWFormatter formatObjectIncludingClass:self.otherSubject]]; 55 | } 56 | 57 | - (NSString *)description 58 | { 59 | return [NSString stringWithFormat:@"equal %@", [KWFormatter formatObjectIncludingClass:self.otherSubject]]; 60 | } 61 | 62 | #pragma mark - Configuring Matchers 63 | 64 | - (void)equal:(id)anObject { 65 | self.otherSubject = anObject; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWGenericMatchEvaluator.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWGenericMatcher.h 3 | // Kiwi 4 | // 5 | // Created by Allen Ding on 1/31/13. 6 | // Copyright (c) 2013 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface KWGenericMatchEvaluator : NSObject 12 | 13 | + (BOOL)isGenericMatcher:(id)object; 14 | 15 | + (BOOL)genericMatcher:(id)matcher matches:(id)object; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWGenericMatchEvaluator.m: -------------------------------------------------------------------------------- 1 | // 2 | // KWGenericMatcher.m 3 | // Kiwi 4 | // 5 | // Created by Allen Ding on 1/31/13. 6 | // Copyright (c) 2013 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import "KWGenericMatchEvaluator.h" 10 | #import "KWStringUtilities.h" 11 | #import "KWObjCUtilities.h" 12 | #import 13 | #import "KWGenericMatcher.h" 14 | 15 | @implementation KWGenericMatchEvaluator 16 | 17 | // Returns true only if the object has a method with the signature "- (BOOL)matches:(id)object" 18 | + (BOOL)isGenericMatcher:(id)object { 19 | Class theClass = object_getClass(object); 20 | 21 | if (theClass == NULL) { 22 | return NO; 23 | } 24 | Method method = class_getInstanceMethod(theClass, @selector(matches:)); 25 | 26 | if (method == NULL) { 27 | return NO; 28 | } 29 | 30 | const char *cEncoding = method_getTypeEncoding(method); 31 | 32 | if (cEncoding == NULL) { 33 | return NO; 34 | } 35 | 36 | NSMethodSignature *signature = [NSMethodSignature signatureWithObjCTypes:cEncoding]; 37 | 38 | if (!KWObjCTypeEqualToObjCType(@encode(BOOL), [signature methodReturnType])) { 39 | return NO; 40 | } 41 | 42 | if ([signature numberOfArguments] != 3) { 43 | return NO; 44 | } 45 | 46 | if (!KWObjCTypeEqualToObjCType(@encode(id), [signature getArgumentTypeAtIndex:2])) { 47 | return NO; 48 | } 49 | 50 | return YES; 51 | } 52 | 53 | + (BOOL)genericMatcher:(id)matcher matches:(id)object { 54 | NSString *targetEncoding = KWEncodingWithObjCTypes(@encode(BOOL), @encode(id), @encode(SEL), @encode(id), nil); 55 | NSMethodSignature *signature = [NSMethodSignature signatureWithObjCTypes:[targetEncoding UTF8String]]; 56 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; 57 | [invocation setSelector:@selector(matches:)]; 58 | [invocation setArgument:&object atIndex:2]; 59 | [invocation invokeWithTarget:matcher]; 60 | BOOL result = NO; 61 | [invocation getReturnValue:&result]; 62 | return result; 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWGenericMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWGenericMatcher.h 3 | // Kiwi 4 | // 5 | // Created by Luke Redpath on 24/01/2011. 6 | // Copyright 2011 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KWMatcher.h" 11 | 12 | @protocol KWGenericMatching 13 | 14 | - (BOOL)matches:(id)object; 15 | 16 | @end 17 | 18 | @interface KWGenericMatcher : KWMatcher 19 | 20 | #pragma mark - Configuring Matchers 21 | 22 | - (void)match:(id)aMatcher; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWGenericMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // KWGenericMatcher.m 3 | // Kiwi 4 | // 5 | // Created by Luke Redpath on 24/01/2011. 6 | // Copyright 2011 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import "KWGenericMatcher.h" 10 | #import "KWGenericMatchEvaluator.h" 11 | 12 | @interface KWGenericMatcher () 13 | 14 | @property (nonatomic, strong) id matcher; 15 | 16 | @end 17 | 18 | @implementation KWGenericMatcher 19 | 20 | #pragma mark - Matching 21 | 22 | - (BOOL)evaluate { 23 | if ([KWGenericMatchEvaluator isGenericMatcher:self.matcher]) { 24 | return [KWGenericMatchEvaluator genericMatcher:self.matcher matches:self.subject]; 25 | } else { 26 | return [self.matcher isEqual:self.subject]; 27 | } 28 | } 29 | 30 | - (NSString *)failureMessageForShould { 31 | return [NSString stringWithFormat:@"expected subject to match %@", self.matcher]; 32 | } 33 | 34 | - (NSString *)description 35 | { 36 | return [NSString stringWithFormat:@"match %@", [self.matcher description]]; 37 | } 38 | 39 | #pragma mark - Getting Matcher Strings 40 | 41 | + (NSArray *)matcherStrings { 42 | return @[@"match:"]; 43 | } 44 | 45 | #pragma mark - Configuring Matchers 46 | 47 | - (void)match:(id)aMatcher; 48 | { 49 | self.matcher = aMatcher; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWGenericMatchingAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+KiwiAdditions.h 3 | // Kiwi 4 | // 5 | // Created by Luke Redpath on 24/01/2011. 6 | // Copyright 2011 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (KiwiGenericMatchingAdditions) 12 | 13 | - (BOOL)isEqualOrMatches:(id)object DEPRECATED_ATTRIBUTE; 14 | 15 | @end 16 | 17 | @interface NSArray (KiwiGenericMatchingAdditions) 18 | 19 | - (BOOL)containsObjectEqualToOrMatching:(id)object DEPRECATED_ATTRIBUTE; 20 | - (BOOL)containsObjectMatching:(id)matcher DEPRECATED_ATTRIBUTE; 21 | 22 | @end 23 | 24 | @interface NSSet (KiwiGenericMatchingAdditions) 25 | 26 | - (BOOL)containsObjectEqualToOrMatching:(id)object DEPRECATED_ATTRIBUTE; 27 | 28 | @end 29 | 30 | @interface NSOrderedSet (KiwiGenericMatchingAdditions) 31 | 32 | - (BOOL)containsObjectEqualToOrMatching:(id)object DEPRECATED_ATTRIBUTE; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWGenericMatchingAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+KiwiAdditions.m 3 | // Kiwi 4 | // 5 | // Created by Luke Redpath on 24/01/2011. 6 | // Copyright 2011 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import "KWGenericMatchingAdditions.h" 10 | #import "KWGenericMatcher.h" 11 | #import "KWGenericMatchEvaluator.h" 12 | 13 | @implementation NSObject (KiwiGenericMatchingAdditions) 14 | 15 | - (BOOL)isEqualOrMatches:(id)object { 16 | if ([KWGenericMatchEvaluator isGenericMatcher:self]) { 17 | return [KWGenericMatchEvaluator genericMatcher:self matches:object]; 18 | } 19 | return [self isEqual:object]; 20 | } 21 | 22 | @end 23 | 24 | @implementation NSArray (KiwiGenericMatchingAdditions) 25 | 26 | - (BOOL)containsObjectEqualToOrMatching:(id)object { 27 | if ([KWGenericMatchEvaluator isGenericMatcher:object]) { 28 | return [self containsObjectMatching:object]; 29 | } 30 | return [self containsObject:object]; 31 | } 32 | 33 | - (BOOL)containsObjectMatching:(id)matcher { 34 | NSIndexSet *indexSet = [self indexesOfObjectsPassingTest:^(id obj, NSUInteger idx, BOOL *stop) { 35 | BOOL matches = [KWGenericMatchEvaluator genericMatcher:matcher matches:obj]; 36 | if (matches) { 37 | *stop = YES; 38 | } 39 | return matches; 40 | }]; 41 | 42 | return (indexSet.count > 0); 43 | } 44 | 45 | @end 46 | 47 | @implementation NSSet (KiwiGenericMatchingAdditions) 48 | 49 | - (BOOL)containsObjectEqualToOrMatching:(id)object { 50 | if ([KWGenericMatchEvaluator isGenericMatcher:object]) { 51 | return [[self allObjects] containsObjectMatching:object]; 52 | } 53 | return [self containsObject:object]; 54 | } 55 | 56 | @end 57 | 58 | @implementation NSOrderedSet (KiwiGenericMatchingAdditions) 59 | 60 | - (BOOL)containsObjectEqualToOrMatching:(id)object { 61 | if ([KWGenericMatchEvaluator isGenericMatcher:object]) { 62 | return [[self array] containsObjectMatching:object]; 63 | } 64 | return [self containsObject:object]; 65 | } 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWHaveMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | #import "KWMatchVerifier.h" 10 | 11 | @interface KWHaveMatcher : KWMatcher 12 | 13 | #pragma mark - Configuring Matchers 14 | 15 | - (void)haveCountOf:(NSUInteger)aCount; 16 | - (void)haveCountOfAtLeast:(NSUInteger)aCount; 17 | - (void)haveCountOfAtMost:(NSUInteger)aCount; 18 | - (void)haveLengthOf:(NSUInteger)aCount; 19 | - (void)haveLengthOfAtLeast:(NSUInteger)aCount; 20 | - (void)haveLengthOfAtMost:(NSUInteger)aCount; 21 | - (void)have:(NSUInteger)aCount itemsForInvocation:(NSInvocation *)anInvocation; 22 | - (void)haveAtLeast:(NSUInteger)aCount itemsForInvocation:(NSInvocation *)anInvocation; 23 | - (void)haveAtMost:(NSUInteger)aCount itemsForInvocation:(NSInvocation *)anInvocation; 24 | 25 | @end 26 | 27 | @protocol KWContainmentCountMatcherTerminals 28 | 29 | #pragma mark - Terminals 30 | 31 | - (id)objects; 32 | - (id)items; 33 | - (id)elements; 34 | 35 | @end 36 | 37 | #pragma mark - Verifying 38 | 39 | @interface KWMatchVerifier(KWHaveMatcherAdditions) 40 | 41 | #pragma mark - Invocation Capturing Methods 42 | 43 | - (id)have:(NSUInteger)aCount; 44 | - (id)haveAtLeast:(NSUInteger)aCount; 45 | - (id)haveAtMost:(NSUInteger)aCount; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWHaveValueMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWHaveValueMatcher.h 3 | // Kiwi 4 | // 5 | // Created by Luke Redpath on 24/01/2011. 6 | // Copyright 2011 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KWMatcher.h" 11 | 12 | @interface KWHaveValueMatcher : KWMatcher 13 | 14 | #pragma mark - Configuring Matchers 15 | 16 | - (void)haveValue:(id)value forKey:(NSString *)key; 17 | - (void)haveValue:(id)value forKeyPath:(NSString *)keyPath; 18 | - (void)haveValueForKey:(NSString *)key; 19 | - (void)haveValueForKeyPath:(NSString *)keyPath; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWInequalityMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | 10 | @interface KWInequalityMatcher : KWMatcher 11 | 12 | #pragma mark - Configuring Matchers 13 | 14 | - (void)beLessThan:(id)aValue; 15 | - (void)beLessThanOrEqualTo:(id)aValue; 16 | - (void)beGreaterThan:(id)aValue; 17 | - (void)beGreaterThanOrEqualTo:(id)aValue; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWNilMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWBeNilMatcher.h 3 | // iOSFalconCore 4 | // 5 | // Created by Luke Redpath on 14/01/2011. 6 | // Copyright 2011 LJR Software Limited. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KWMatcher.h" 11 | 12 | @interface KWNilMatcher : KWMatcher 13 | 14 | - (void)beNil; 15 | - (void)beNonNil; 16 | 17 | - (void)beNil:(BOOL)workaroundArgument; 18 | - (void)beNonNil:(BOOL)workaroundArgument; 19 | 20 | + (BOOL)verifyNilSubject; 21 | + (BOOL)verifyNonNilSubject; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWNilMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // KWBeNilMatcher.m 3 | // iOSFalconCore 4 | // 5 | // Created by Luke Redpath on 14/01/2011. 6 | // Copyright 2011 LJR Software Limited. All rights reserved. 7 | // 8 | 9 | #import "KWNilMatcher.h" 10 | #import "KWExample.h" 11 | #import "KWExampleSuiteBuilder.h" 12 | #import "KWFormatter.h" 13 | #import "KWMatchVerifier.h" 14 | #import "KWVerifying.h" 15 | 16 | @interface KWNilMatcher () 17 | 18 | @property (nonatomic, assign) BOOL expectsNil; 19 | 20 | @end 21 | 22 | @implementation KWNilMatcher 23 | 24 | #pragma mark - Getting Matcher Strings 25 | 26 | + (NSArray *)matcherStrings { 27 | return @[@"beNil", @"beNil:", @"beNonNil", @"beNonNil:"]; 28 | } 29 | 30 | #pragma mark - Matching 31 | 32 | - (BOOL)isNilMatcher { 33 | return YES; 34 | } 35 | 36 | - (BOOL)evaluate { 37 | if (self.expectsNil) { 38 | return (self.subject == nil); 39 | } else { 40 | return (self.subject != nil); 41 | } 42 | } 43 | 44 | // These two methods gets invoked by be(Non)Nil macro in case the subject is nil 45 | // (and therefore cannot have a verifier attached). 46 | 47 | + (BOOL)verifyNilSubject { 48 | return [self verifySubjectExpectingNil:YES]; 49 | } 50 | 51 | + (BOOL)verifyNonNilSubject { 52 | return [self verifySubjectExpectingNil:NO]; 53 | } 54 | 55 | #pragma mark Getting Failure Messages 56 | 57 | - (NSString *)failureMessageForShould { 58 | if (self.expectsNil) { 59 | return [NSString stringWithFormat:@"expected subject to be nil, got %@", 60 | [KWFormatter formatObject:self.subject]]; 61 | } else { 62 | return [NSString stringWithFormat:@"expected subject not to be nil"]; 63 | } 64 | } 65 | 66 | - (NSString *)failureMessageForShouldNot { 67 | if (self.expectsNil) { 68 | return [NSString stringWithFormat:@"expected subject not to be nil"]; 69 | } else { 70 | return [NSString stringWithFormat:@"expected subject to be nil, got %@", 71 | [KWFormatter formatObject:self.subject]]; 72 | } 73 | } 74 | 75 | - (NSString *)description { 76 | return [NSString stringWithFormat:@"be %@nil", self.expectsNil ? @"" : @"non "]; 77 | } 78 | 79 | - (void)beNil { 80 | self.expectsNil = YES; 81 | } 82 | - (void)beNil:(BOOL)workaroundArgument { 83 | self.expectsNil = YES; 84 | } 85 | 86 | - (void)beNonNil { 87 | self.expectsNil = NO; 88 | } 89 | - (void)beNonNil:(BOOL)workaroundArgument { 90 | self.expectsNil = NO; 91 | } 92 | 93 | #pragma mark - Internal Methods 94 | 95 | + (BOOL)verifySubjectExpectingNil:(BOOL)expectNil { 96 | KWExample *currentExample = [[KWExampleSuiteBuilder sharedExampleSuiteBuilder] currentExample]; 97 | id verifier = currentExample.unresolvedVerifier; 98 | 99 | if (verifier && ![verifier subject] && [verifier isKindOfClass:[KWMatchVerifier class]]) { 100 | KWMatchVerifier *matchVerifier = (KWMatchVerifier *)verifier; 101 | if (expectNil) { 102 | [matchVerifier performSelector:@selector(beNil)]; 103 | } else { 104 | [matchVerifier performSelector:@selector(beNonNil)]; 105 | } 106 | currentExample.unresolvedVerifier = nil; 107 | return NO; 108 | } 109 | return YES; 110 | } 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWNotificationMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWNotificationMatcher.h 3 | // 4 | // Created by Paul Zabelin on 7/12/12. 5 | // Copyright (c) 2012 Blazing Cloud, Inc. All rights reserved. 6 | // 7 | 8 | #import "KWMatcher.h" 9 | 10 | typedef void (^PostedNotificationBlock)(NSNotification* note); 11 | 12 | @interface KWNotificationMatcher : KWMatcher 13 | 14 | - (void)bePosted; 15 | - (void)bePostedWithObject:(id)object; 16 | - (void)bePostedWithUserInfo:(NSDictionary *)userInfo; 17 | - (void)bePostedWithObject:(id)object andUserInfo:(NSDictionary *)userInfo DEPRECATED_MSG_ATTRIBUTE("Use -bePostedWithObject:userInfo: method instead."); 18 | - (void)bePostedWithObject:(id)object userInfo:(NSDictionary *)userInfo; 19 | - (void)bePostedEvaluatingBlock:(PostedNotificationBlock)block; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWReceiveMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWCountType.h" 9 | #import "KWMatcher.h" 10 | #import "KWMatchVerifier.h" 11 | 12 | @class KWMessagePattern; 13 | @class KWMessageTracker; 14 | 15 | @interface KWReceiveMatcher : KWMatcher 16 | 17 | @property (nonatomic, assign) BOOL willEvaluateMultipleTimes; 18 | @property (nonatomic, assign) BOOL willEvaluateAgainstNegativeExpectation; 19 | 20 | #pragma mark - Configuring Matchers 21 | 22 | - (void)receive:(SEL)aSelector; 23 | - (void)receive:(SEL)aSelector withCount:(NSUInteger)aCount; 24 | - (void)receive:(SEL)aSelector withCountAtLeast:(NSUInteger)aCount; 25 | - (void)receive:(SEL)aSelector withCountAtMost:(NSUInteger)aCount; 26 | - (void)receive:(SEL)aSelector andReturn:(id)aValue; 27 | - (void)receive:(SEL)aSelector andReturn:(id)aValue withCount:(NSUInteger)aCount; 28 | - (void)receive:(SEL)aSelector andReturn:(id)aValue withCountAtLeast:(NSUInteger)aCount; 29 | - (void)receive:(SEL)aSelector andReturn:(id)aValue withCountAtMost:(NSUInteger)aCount; 30 | 31 | // These methods will become private 32 | - (void)receiveMessagePattern:(KWMessagePattern *)aMessagePattern countType:(KWCountType)aCountType count:(NSUInteger)aCount; 33 | - (void)receiveMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue countType:(KWCountType)aCountType count:(NSUInteger)aCount; 34 | 35 | @end 36 | 37 | @interface KWMatchVerifier(KWReceiveMatcherAdditions) 38 | 39 | #pragma mark - Verifying 40 | 41 | - (void)receive:(SEL)aSelector withArguments:(id)firstArgument, ...; 42 | - (void)receive:(SEL)aSelector withCount:(NSUInteger)aCount arguments:(id)firstArgument, ...; 43 | - (void)receive:(SEL)aSelector withCountAtLeast:(NSUInteger)aCount arguments:(id)firstArgument, ...; 44 | - (void)receive:(SEL)aSelector withCountAtMost:(NSUInteger)aCount arguments:(id)firstArgument, ...; 45 | - (void)receive:(SEL)aSelector andReturn:(id)aValue withArguments:(id)firstArgument, ...; 46 | - (void)receive:(SEL)aSelector andReturn:(id)aValue withCount:(NSUInteger)aCount arguments:(id)firstArgument, ...; 47 | - (void)receive:(SEL)aSelector andReturn:(id)aValue withCountAtLeast:(NSUInteger)aCount arguments:(id)firstArgument, ...; 48 | - (void)receive:(SEL)aSelector andReturn:(id)aValue withCountAtMost:(NSUInteger)aCount arguments:(id)firstArgument, ...; 49 | 50 | #pragma mark Invocation Capturing Methods 51 | 52 | - (id)receive DEPRECATED_ATTRIBUTE; 53 | - (id)receiveWithCount:(NSUInteger)aCount DEPRECATED_ATTRIBUTE; 54 | - (id)receiveWithCountAtLeast:(NSUInteger)aCount DEPRECATED_ATTRIBUTE; 55 | - (id)receiveWithCountAtMost:(NSUInteger)aCount DEPRECATED_ATTRIBUTE; 56 | - (id)receiveAndReturn:(id)aValue DEPRECATED_ATTRIBUTE; 57 | - (id)receiveAndReturn:(id)aValue withCount:(NSUInteger)aCount DEPRECATED_ATTRIBUTE; 58 | - (id)receiveAndReturn:(id)aValue withCountAtLeast:(NSUInteger)aCount DEPRECATED_ATTRIBUTE; 59 | - (id)receiveAndReturn:(id)aValue withCountAtMost:(NSUInteger)aCount DEPRECATED_ATTRIBUTE; 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWRegularExpressionPatternMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWRegularExpressionPatternMatcher.h 3 | // Kiwi 4 | // 5 | // Created by Kristopher Johnson on 4/11/13. 6 | // Copyright (c) 2013 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import "KiwiConfiguration.h" 10 | #import "KWMatcher.h" 11 | 12 | @interface KWRegularExpressionPatternMatcher : KWMatcher 13 | 14 | - (void)matchPattern:(NSString *)pattern; 15 | 16 | - (void)matchPattern:(NSString *)pattern options:(NSRegularExpressionOptions)options; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWRegularExpressionPatternMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // KWRegularExpressionPatternMatcher.m 3 | // Kiwi 4 | // 5 | // Created by Kristopher Johnson on 4/11/13. 6 | // Copyright (c) 2013 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import "KWRegularExpressionPatternMatcher.h" 10 | #import "KWFormatter.h" 11 | 12 | 13 | @interface KWRegularExpressionPatternMatcher () 14 | 15 | @property (nonatomic, copy) NSString *pattern; 16 | @property (nonatomic) NSRegularExpressionOptions options; 17 | 18 | @end 19 | 20 | 21 | @implementation KWRegularExpressionPatternMatcher 22 | 23 | 24 | #pragma mark - Getting Matcher Strings 25 | 26 | + (NSArray *)matcherStrings { 27 | return @[@"matchPattern:", @"matchPattern:options:"]; 28 | } 29 | 30 | #pragma mark - Matching 31 | 32 | - (BOOL)evaluate { 33 | if (![self.subject isKindOfClass:[NSString class]]) { 34 | return NO; 35 | } 36 | NSString *subjectString = (NSString *)self.subject; 37 | NSRange subjectStringRange = NSMakeRange(0, subjectString.length); 38 | 39 | NSError *error = nil; 40 | NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:self.pattern 41 | options:self.options 42 | error:&error]; 43 | if (!regex) { 44 | NSLog(@"%s: Unable to create regular expression for pattern \"%@\": %@", 45 | __PRETTY_FUNCTION__, self.pattern, [error localizedDescription]); 46 | return NO; 47 | } 48 | 49 | NSUInteger numberOfMatches = [regex numberOfMatchesInString:subjectString 50 | options:0 51 | range:subjectStringRange]; 52 | return (numberOfMatches == 1); 53 | } 54 | 55 | #pragma mark - Getting Failure Messages 56 | 57 | - (NSString *)failureMessageForShould { 58 | return [NSString stringWithFormat:@"%@ did not match pattern \"%@\"", 59 | [KWFormatter formatObject:self.subject], 60 | self.pattern]; 61 | } 62 | 63 | - (NSString *)failureMessageForShouldNot { 64 | return [NSString stringWithFormat:@"expected subject not to match pattern \"%@\"", 65 | self.pattern]; 66 | } 67 | 68 | - (NSString *)description { 69 | return [NSString stringWithFormat:@"match pattern \"%@\"", self.pattern]; 70 | } 71 | 72 | - (void)matchPattern:(NSString *)pattern { 73 | self.pattern = pattern; 74 | self.options = 0; 75 | } 76 | 77 | - (void)matchPattern:(NSString *)pattern options:(NSRegularExpressionOptions)options { 78 | self.pattern = pattern; 79 | self.options = options; 80 | } 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWRespondToSelectorMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWMatcher.h" 9 | 10 | @interface KWRespondToSelectorMatcher : KWMatcher 11 | 12 | #pragma mark - Configuring Matchers 13 | 14 | - (void)respondToSelector:(SEL)aSelector; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWRespondToSelectorMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWRespondToSelectorMatcher.h" 8 | #import "KWFormatter.h" 9 | 10 | @interface KWRespondToSelectorMatcher() 11 | 12 | #pragma mark - Properties 13 | 14 | @property (nonatomic, assign) SEL selector; 15 | 16 | @end 17 | 18 | @implementation KWRespondToSelectorMatcher 19 | 20 | #pragma mark - Getting Matcher Strings 21 | 22 | + (NSArray *)matcherStrings { 23 | return @[@"respondToSelector:"]; 24 | } 25 | 26 | #pragma mark - Matching 27 | 28 | - (BOOL)evaluate { 29 | return [self.subject respondsToSelector:self.selector]; 30 | } 31 | 32 | #pragma mark - Getting Failure Messages 33 | 34 | - (NSString *)failureMessageForShould { 35 | return [NSString stringWithFormat:@"expected subject to respond to -%@", 36 | NSStringFromSelector(self.selector)]; 37 | } 38 | 39 | - (NSString *)description { 40 | return [NSString stringWithFormat:@"respond to -%@", NSStringFromSelector(self.selector)]; 41 | } 42 | 43 | #pragma mark - Configuring Matchers 44 | 45 | - (void)respondToSelector:(SEL)aSelector { 46 | self.selector = aSelector; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWStringContainsMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWStringContainsMatcher.h 3 | // Kiwi 4 | // 5 | // Created by Stewart Gleadow on 7/06/12. 6 | // Copyright (c) 2012 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KWGenericMatcher.h" 11 | 12 | @interface KWStringContainsMatcher : NSObject 13 | 14 | + (id)matcherWithSubstring:(NSString *)aSubstring DEPRECATED_ATTRIBUTE; 15 | - (id)initWithSubstring:(NSString *)aSubstring DEPRECATED_ATTRIBUTE; 16 | 17 | @end 18 | 19 | #define hasSubstring(substring) [KWStringContainsMatcher matcherWithSubstring:substring] 20 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWStringContainsMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // StringContainsMatcher.m 3 | // Kiwi 4 | // 5 | // Created by Stewart Gleadow on 7/06/12. 6 | // Copyright (c) 2012 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import "KWStringContainsMatcher.h" 10 | 11 | @interface KWStringContainsMatcher(){} 12 | @property (nonatomic, copy) NSString *substring; 13 | @end 14 | 15 | @implementation KWStringContainsMatcher 16 | 17 | + (id)matcherWithSubstring:(NSString *)aSubstring { 18 | return [[self alloc] initWithSubstring:aSubstring]; 19 | } 20 | 21 | - (id)initWithSubstring:(NSString *)aSubstring { 22 | self = [super init]; 23 | if (self) { 24 | _substring = [aSubstring copy]; 25 | } 26 | return self; 27 | } 28 | 29 | 30 | - (BOOL)matches:(id)item { 31 | if (![item respondsToSelector:@selector(rangeOfString:)]) { 32 | return NO; 33 | } 34 | 35 | return [item rangeOfString:self.substring].location != NSNotFound; 36 | } 37 | 38 | - (NSString *)description { 39 | return [NSString stringWithFormat:@"a string with substring '%@'", self.substring]; 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWStringPrefixMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // StringPrefixMatcher.h 3 | // Kiwi 4 | // 5 | // Created by Luke Redpath on 17/01/2011. 6 | // Copyright 2011 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface KWStringPrefixMatcher : NSObject 12 | 13 | + (id)matcherWithPrefix:(NSString *)aPrefix; 14 | - (id)initWithPrefix:(NSString *)aPrefix; 15 | 16 | @end 17 | 18 | #define hasPrefix(prefix) [KWStringPrefixMatcher matcherWithPrefix:prefix] 19 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWStringPrefixMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // StringPrefixMatcher.m 3 | // Kiwi 4 | // 5 | // Created by Luke Redpath on 17/01/2011. 6 | // Copyright 2011 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import "KWStringPrefixMatcher.h" 10 | 11 | @interface KWStringPrefixMatcher(){} 12 | @property (nonatomic, copy) NSString *prefix; 13 | @end 14 | 15 | @implementation KWStringPrefixMatcher 16 | 17 | + (id)matcherWithPrefix:(NSString *)aPrefix { 18 | return [[self alloc] initWithPrefix:aPrefix]; 19 | } 20 | 21 | - (id)initWithPrefix:(NSString *)aPrefix { 22 | self = [super init]; 23 | if (self) { 24 | _prefix = [aPrefix copy]; 25 | } 26 | return self; 27 | } 28 | 29 | 30 | - (BOOL)matches:(id)item { 31 | if (![item respondsToSelector:@selector(hasPrefix:)]) 32 | return NO; 33 | 34 | return [item hasPrefix:self.prefix]; 35 | } 36 | 37 | - (NSString *)description { 38 | return [NSString stringWithFormat:@"a string with prefix '%@'", self.prefix]; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Matchers/KWUserDefinedMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWUserDefinedMatcher.h 3 | // Kiwi 4 | // 5 | // Created by Luke Redpath on 16/06/2011. 6 | // Copyright 2011 Allen Ding. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KWMatcher.h" 11 | 12 | #pragma clang diagnostic push 13 | #pragma clang diagnostic ignored "-Wstrict-prototypes" 14 | typedef BOOL (^KWUserDefinedMatcherBlock)(); 15 | #pragma clang diagnostic pop 16 | 17 | @interface KWUserDefinedMatcher : KWMatcher 18 | 19 | @property (nonatomic, assign) SEL selector; 20 | @property (nonatomic, copy) NSString *failureMessageForShould; 21 | @property (nonatomic, copy) NSString *failureMessageForShouldNot; 22 | @property (nonatomic, copy) KWUserDefinedMatcherBlock matcherBlock; 23 | @property (nonatomic, copy) NSString *description; 24 | 25 | + (id)matcherWithSubject:(id)aSubject block:(KWUserDefinedMatcherBlock)aBlock; 26 | - (id)initWithSubject:(id)aSubject block:(KWUserDefinedMatcherBlock)aBlock; 27 | @end 28 | 29 | #pragma mark - 30 | 31 | typedef NSString * (^KWUserDefinedMatcherMessageBlock)(id); 32 | 33 | @interface KWUserDefinedMatcherBuilder : NSObject 34 | 35 | @property (nonatomic, copy, readonly) NSString *key; 36 | 37 | + (id)builder; 38 | + (id)builderForSelector:(SEL)aSelector; 39 | - (id)initWithSelector:(SEL)aSelector; 40 | 41 | #pragma mark - Configuring The Matcher 42 | 43 | - (void)match:(KWUserDefinedMatcherBlock)block; 44 | - (void)failureMessageForShould:(KWUserDefinedMatcherMessageBlock)block; 45 | - (void)failureMessageForShouldNot:(KWUserDefinedMatcherMessageBlock)block; 46 | - (void)description:(NSString *)description; 47 | 48 | #pragma mark - Buiding The Matcher 49 | 50 | - (KWUserDefinedMatcher *)buildMatcherWithSubject:(id)subject; 51 | @end 52 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Mocking/KWMock.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWInvocationCapturer.h" 9 | 10 | @class KWMessagePattern; 11 | @class KWCaptureSpy; 12 | 13 | @protocol KWMessageSpying; 14 | @protocol KWVerifying; 15 | 16 | @interface KWMock : NSObject 17 | 18 | #pragma mark - Initializing 19 | 20 | - (id)initForClass:(Class)aClass; 21 | - (id)initForProtocol:(Protocol *)aProtocol; 22 | - (id)initWithName:(NSString *)aName forClass:(Class)aClass; 23 | - (id)initWithName:(NSString *)aName forProtocol:(Protocol *)aProtocol; 24 | 25 | - (id)initAsNullMockForClass:(Class)aClass; 26 | - (id)initAsNullMockForProtocol:(Protocol *)aProtocol; 27 | - (id)initAsNullMockWithName:(NSString *)aName forClass:(Class)aClass; 28 | - (id)initAsNullMockWithName:(NSString *)aName forProtocol:(Protocol *)aProtocol; 29 | 30 | - (id)initAsPartialMockForObject:(id)object; 31 | - (id)initAsPartialMockWithName:(NSString *)aName forObject:(id)object; 32 | 33 | + (id)mockForClass:(Class)aClass; 34 | + (id)mockForProtocol:(Protocol *)aProtocol; 35 | + (id)mockWithName:(NSString *)aName forClass:(Class)aClass; 36 | + (id)mockWithName:(NSString *)aName forProtocol:(Protocol *)aProtocol; 37 | 38 | + (id)nullMockForClass:(Class)aClass; 39 | + (id)nullMockForProtocol:(Protocol *)aProtocol; 40 | + (id)nullMockWithName:(NSString *)aName forClass:(Class)aClass ; 41 | + (id)nullMockWithName:(NSString *)aName forProtocol:(Protocol *)aProtocol; 42 | 43 | + (id)partialMockForObject:(id)object; 44 | + (id)partialMockWithName:(NSString *)aName forObject:(id)object; 45 | 46 | #pragma mark - Properties 47 | 48 | @property (nonatomic, assign, readonly) BOOL isNullMock; 49 | @property (nonatomic, assign, readonly) BOOL isPartialMock; 50 | @property (nonatomic, copy, readonly) NSString *mockName; 51 | @property (nonatomic, assign, readonly) Class mockedClass; 52 | @property (nonatomic, strong, readonly) id mockedObject; 53 | @property (nonatomic, assign, readonly) Protocol *mockedProtocol; 54 | 55 | #pragma mark - Stubbing Methods 56 | 57 | - (void)stub:(SEL)aSelector; 58 | - (void)stub:(SEL)aSelector withBlock:(id (^)(NSArray *params))block; 59 | - (void)stub:(SEL)aSelector withArguments:(id)firstArgument, ...; 60 | - (void)stub:(SEL)aSelector andReturn:(id)aValue; 61 | - (void)stub:(SEL)aSelector andReturn:(id)aValue withArguments:(id)firstArgument, ...; 62 | 63 | - (id)stub; 64 | - (id)stubAndReturn:(id)aValue; 65 | - (id)stubAndReturn:(id)aValue times:(id)times afterThatReturn:(id)aSecondValue; 66 | 67 | - (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue; 68 | - (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue times:(id)times afterThatReturn:(id)aSecondValue; 69 | 70 | - (void)clearStubs; 71 | 72 | #pragma mark - Spying on Messages 73 | 74 | - (void)addMessageSpy:(id)aSpy forMessagePattern:(KWMessagePattern *)aMessagePattern; 75 | - (void)removeMessageSpy:(id)aSpy forMessagePattern:(KWMessagePattern *)aMessagePattern; 76 | 77 | 78 | #pragma mark - Expecting Messages 79 | 80 | - (void)expect:(SEL)aSelector; 81 | - (void)expect:(SEL)aSelector withArguments:(id)firstArgument, ...; 82 | 83 | - (id)expect; 84 | 85 | - (void)expectMessagePattern:(KWMessagePattern *)aMessagePattern; 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Mocking/NSObject+KiwiMockAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @protocol KiwiMockAdditions 10 | 11 | #pragma mark - Creating Mocks 12 | 13 | + (id)mock; 14 | + (id)mockWithName:(NSString *)aName; 15 | 16 | + (id)nullMock; 17 | + (id)nullMockWithName:(NSString *)aName; 18 | 19 | @end 20 | 21 | @interface NSObject(KiwiMockAdditions) 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Mocking/NSObject+KiwiMockAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "NSObject+KiwiMockAdditions.h" 8 | #import "KWMock.h" 9 | 10 | @implementation NSObject(KiwiMockAdditions) 11 | 12 | #pragma mark - Creating Mocks 13 | 14 | + (id)mock { 15 | return [KWMock mockForClass:[self class]]; 16 | } 17 | 18 | + (id)mockWithName:(NSString *)aName { 19 | return [KWMock mockWithName:aName forClass:[self class]]; 20 | } 21 | 22 | + (id)nullMock { 23 | return [KWMock nullMockForClass:[self class]]; 24 | } 25 | 26 | + (id)nullMockWithName:(NSString *)aName { 27 | return [KWMock nullMockWithName:aName forClass:[self class]]; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWAfterAllNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWBlockNode.h" 9 | #import "KWExampleNode.h" 10 | 11 | @interface KWAfterAllNode : KWBlockNode 12 | 13 | #pragma mark - Initializing 14 | 15 | + (id)afterAllNodeWithCallSite:(KWCallSite *)aCallSite block:(void (^)(void))block; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWAfterAllNode.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWAfterAllNode.h" 8 | #import "KWExampleNodeVisitor.h" 9 | 10 | @implementation KWAfterAllNode 11 | 12 | #pragma mark - Initializing 13 | 14 | + (id)afterAllNodeWithCallSite:(KWCallSite *)aCallSite block:(void (^)(void))block { 15 | return [[self alloc] initWithCallSite:aCallSite description:nil block:block]; 16 | } 17 | 18 | #pragma mark - Accepting Visitors 19 | 20 | - (void)acceptExampleNodeVisitor:(id)aVisitor { 21 | [aVisitor visitAfterAllNode:self]; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWAfterEachNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWBlockNode.h" 9 | #import "KWExampleNode.h" 10 | 11 | @interface KWAfterEachNode : KWBlockNode 12 | 13 | #pragma mark - Initializing 14 | 15 | + (id)afterEachNodeWithCallSite:(KWCallSite *)aCallSite block:(void (^)(void))block; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWAfterEachNode.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWAfterEachNode.h" 8 | #import "KWExampleNodeVisitor.h" 9 | 10 | @implementation KWAfterEachNode 11 | 12 | #pragma mark - Initializing 13 | 14 | + (id)afterEachNodeWithCallSite:(KWCallSite *)aCallSite block:(void (^)(void))block { 15 | return [[self alloc] initWithCallSite:aCallSite description:nil block:block]; 16 | } 17 | 18 | #pragma mark - Accepting Visitors 19 | 20 | - (void)acceptExampleNodeVisitor:(id)aVisitor { 21 | [aVisitor visitAfterEachNode:self]; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWBeforeAllNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWBlockNode.h" 9 | #import "KWExampleNode.h" 10 | 11 | @interface KWBeforeAllNode : KWBlockNode 12 | 13 | #pragma mark - Initializing 14 | 15 | + (id)beforeAllNodeWithCallSite:(KWCallSite *)aCallSite block:(void (^)(void))block; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWBeforeAllNode.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWBeforeAllNode.h" 8 | #import "KWExampleNodeVisitor.h" 9 | 10 | @implementation KWBeforeAllNode 11 | 12 | #pragma mark - Initializing 13 | 14 | + (id)beforeAllNodeWithCallSite:(KWCallSite *)aCallSite block:(void (^)(void))block { 15 | return [[self alloc] initWithCallSite:aCallSite description:nil block:block]; 16 | } 17 | 18 | #pragma mark - Accepting Visitors 19 | 20 | - (void)acceptExampleNodeVisitor:(id)aVisitor { 21 | [aVisitor visitBeforeAllNode:self]; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWBeforeEachNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWBlockNode.h" 9 | #import "KWExampleNode.h" 10 | 11 | @interface KWBeforeEachNode : KWBlockNode 12 | 13 | #pragma mark - Initializing 14 | 15 | + (id)beforeEachNodeWithCallSite:(KWCallSite *)aCallSite block:(void (^)(void))block; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWBeforeEachNode.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWBeforeEachNode.h" 8 | #import "KWExampleNodeVisitor.h" 9 | 10 | @implementation KWBeforeEachNode 11 | 12 | #pragma mark - Initializing 13 | 14 | + (id)beforeEachNodeWithCallSite:(KWCallSite *)aCallSite block:(void (^)(void))block { 15 | return [[self alloc] initWithCallSite:aCallSite description:nil block:block]; 16 | } 17 | 18 | #pragma mark - Accepting Visitors 19 | 20 | - (void)acceptExampleNodeVisitor:(id)aVisitor { 21 | [aVisitor visitBeforeEachNode:self]; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWBlockNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWBlock.h" 9 | 10 | @class KWCallSite; 11 | 12 | @interface KWBlockNode : NSObject 13 | 14 | #pragma mark - Initializing 15 | 16 | - (id)initWithCallSite:(KWCallSite *)aCallSite description:(NSString *)aDescription block:(void (^)(void))block; 17 | 18 | #pragma mark - Getting Call Sites 19 | 20 | @property (nonatomic, strong, readonly) KWCallSite *callSite; 21 | 22 | #pragma mark - Getting Descriptions 23 | 24 | @property (nonatomic, copy) NSString *description; 25 | 26 | #pragma mark - Getting Blocks 27 | 28 | @property (nonatomic, copy, readonly) void (^block)(void); 29 | 30 | #pragma mark - Performing blocks 31 | 32 | - (void)performBlock; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWBlockNode.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWBlockNode.h" 8 | 9 | @implementation KWBlockNode 10 | 11 | @synthesize description = _description; 12 | 13 | #pragma mark - Initializing 14 | 15 | - (id)initWithCallSite:(KWCallSite *)aCallSite description:(NSString *)aDescription block:(void (^)(void))block { 16 | self = [super init]; 17 | if (self) { 18 | _callSite = aCallSite; 19 | _description = [aDescription copy]; 20 | _block = [block copy]; 21 | } 22 | 23 | return self; 24 | } 25 | 26 | - (void)performBlock { 27 | if (self.block != nil) { self.block(); } 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWContextNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWExampleNode.h" 9 | 10 | @class KWAfterAllNode; 11 | @class KWAfterEachNode; 12 | @class KWBeforeAllNode; 13 | @class KWBeforeEachNode; 14 | @class KWCallSite; 15 | @class KWLetNode; 16 | @class KWItNode; 17 | @class KWPendingNode; 18 | @class KWRegisterMatchersNode; 19 | @class KWExample; 20 | 21 | @interface KWContextNode : NSObject 22 | 23 | #pragma mark - Initializing 24 | 25 | - (id)initWithCallSite:(KWCallSite *)aCallSite parentContext:(KWContextNode *)node description:(NSString *)aDescription; 26 | 27 | + (id)contextNodeWithCallSite:(KWCallSite *)aCallSite parentContext:(KWContextNode *)contextNode description:(NSString *)aDescription; 28 | 29 | #pragma mark - Getting Call Sites 30 | 31 | @property (nonatomic, weak, readonly) KWCallSite *callSite; 32 | 33 | #pragma mark - Getting Descriptions 34 | 35 | @property (readonly, copy) NSString *description; 36 | 37 | #pragma mark - Managing Nodes 38 | 39 | @property (nonatomic, strong) KWBeforeAllNode *beforeAllNode; 40 | @property (nonatomic, strong) KWAfterAllNode *afterAllNode; 41 | @property (nonatomic, strong) KWBeforeEachNode *beforeEachNode; 42 | @property (nonatomic, strong) KWAfterEachNode *afterEachNode; 43 | @property (nonatomic, readonly) NSArray *nodes; 44 | @property (nonatomic, readonly) NSArray *registerMatchersNodes; 45 | @property (nonatomic, readonly) NSArray *letNodes; 46 | 47 | @property (nonatomic, readonly) KWContextNode *parentContext; 48 | 49 | @property (nonatomic, assign) BOOL isFocused; 50 | 51 | - (void)addContextNode:(KWContextNode *)aNode; 52 | - (void)addLetNode:(KWLetNode *)aNode; 53 | - (void)addRegisterMatchersNode:(KWRegisterMatchersNode *)aNode; 54 | - (void)addItNode:(KWItNode *)aNode; 55 | - (void)addPendingNode:(KWPendingNode *)aNode; 56 | 57 | - (KWLetNode *)letNodeTree; 58 | 59 | - (void)performExample:(KWExample *)example withBlock:(void (^)(void))exampleBlock; 60 | 61 | #pragma mark - Accepting Visitors 62 | 63 | - (void)acceptExampleNodeVisitor:(id)aVisitor; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWExampleNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @class KWContextNode; 10 | @protocol KWExampleNodeVisitor; 11 | 12 | @protocol KWExampleNode 13 | 14 | #pragma mark - Accepting Visitors 15 | 16 | - (void)acceptExampleNodeVisitor:(id)aVisitor; 17 | 18 | @optional 19 | 20 | - (NSArray *)contextStack; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWItNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWBlockNode.h" 9 | #import "KWExampleNode.h" 10 | 11 | @class KWPendingNode; 12 | @class KWExample; 13 | @class KWContextNode; 14 | 15 | @interface KWItNode : KWBlockNode 16 | 17 | @property (nonatomic, strong) KWExample *example; 18 | @property (nonatomic, weak, readonly) KWContextNode *context; 19 | 20 | #pragma mark - Initializing 21 | 22 | + (id)itNodeWithCallSite:(KWCallSite *)aCallSite 23 | description:(NSString *)aDescription 24 | context:(KWContextNode *)context 25 | block:(void (^)(void))block; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWItNode.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWItNode.h" 8 | #import "KWExampleNodeVisitor.h" 9 | #import "KWExample.h" 10 | #import "KWVerifying.h" 11 | #import "KWContextNode.h" 12 | 13 | @interface KWItNode () 14 | 15 | @property (nonatomic, weak) KWContextNode *context; 16 | 17 | @end 18 | 19 | @implementation KWItNode 20 | 21 | #pragma mark - Initializing 22 | 23 | + (id)itNodeWithCallSite:(KWCallSite *)aCallSite 24 | description:(NSString *)aDescription 25 | context:(KWContextNode *)context 26 | block:(void (^)(void))block { 27 | KWItNode *itNode = [[self alloc] initWithCallSite:aCallSite description:aDescription block:block]; 28 | itNode.context = context; 29 | return itNode; 30 | } 31 | 32 | #pragma mark - Accepting Visitors 33 | 34 | - (void)acceptExampleNodeVisitor:(id)aVisitor { 35 | [aVisitor visitItNode:self]; 36 | } 37 | 38 | #pragma mark - Runtime Description support 39 | 40 | - (NSString *)description { 41 | NSString *description = [super description]; 42 | if (description == nil) { 43 | description = [self.example generateDescriptionForAnonymousItNode]; 44 | } 45 | return description; 46 | } 47 | 48 | #pragma mark - Accessing the context stack 49 | 50 | - (NSArray *)contextStack { 51 | NSMutableArray *contextStack = [NSMutableArray array]; 52 | 53 | KWContextNode *currentContext = _context; 54 | 55 | while (currentContext) { 56 | [contextStack addObject:currentContext]; 57 | currentContext = currentContext.parentContext; 58 | } 59 | return contextStack; 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWLetNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWExampleNode.h" 9 | 10 | @interface KWLetNode : NSObject 11 | 12 | - (instancetype)initWithSymbolName:(NSString *)aSymbolName objectRef:(id *)anObjectRef block:(id (^)(void))block; 13 | + (instancetype)letNodeWithSymbolName:(NSString *)aSymbolName objectRef:(id *)anObjectRef block:(id (^)(void))block; 14 | 15 | @property (nonatomic, copy) NSString *symbolName; 16 | @property (nonatomic, copy) id (^block)(void); 17 | @property (nonatomic, readonly) __autoreleasing id *objectRef; 18 | 19 | - (id)evaluate; 20 | - (void)evaluateTree; 21 | 22 | - (void)addLetNode:(KWLetNode *)aNode; 23 | - (void)unlink; 24 | 25 | // The parent/child relationship describes let nodes declared in nested 26 | // contexts -- evaluating a node returns the value of the deepest 27 | // evaluated child. 28 | @property (nonatomic, readonly, weak) KWLetNode *parent; 29 | @property (nonatomic, readonly, strong) KWLetNode *child; 30 | 31 | // The next/previous relationship describes the order in which nodes 32 | // of different symbols were declared. 33 | @property (nonatomic, readonly, strong) KWLetNode *next; 34 | @property (nonatomic, readonly, weak) KWLetNode *previous; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWPendingNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWExampleNode.h" 9 | 10 | @class KWContextNode; 11 | @class KWCallSite; 12 | 13 | @interface KWPendingNode : NSObject 14 | 15 | @property (nonatomic, readonly, strong) KWContextNode *context; 16 | 17 | #pragma mark - Initializing 18 | 19 | - (id)initWithCallSite:(KWCallSite *)aCallSite context:(KWContextNode *)context description:(NSString *)aDescription; 20 | 21 | + (id)pendingNodeWithCallSite:(KWCallSite *)aCallSite context:(KWContextNode *)context description:(NSString *)aDescription; 22 | 23 | #pragma mark - Getting Call Sites 24 | 25 | @property (nonatomic, readonly) KWCallSite *callSite; 26 | 27 | #pragma mark - Getting Descriptions 28 | 29 | @property (readonly, copy) NSString *description; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWPendingNode.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWPendingNode.h" 8 | 9 | #import "KWCallSite.h" 10 | #import "KWContextNode.h" 11 | #import "KWExampleNodeVisitor.h" 12 | 13 | @implementation KWPendingNode 14 | 15 | @synthesize description = _description; 16 | 17 | #pragma mark - Initializing 18 | 19 | - (id)initWithCallSite:(KWCallSite *)aCallSite context:(KWContextNode *)context description:(NSString *)aDescription { 20 | self = [super init]; 21 | if (self) { 22 | _callSite = aCallSite; 23 | _description = [aDescription copy]; 24 | _context = context; 25 | } 26 | 27 | return self; 28 | } 29 | 30 | + (id)pendingNodeWithCallSite:(KWCallSite *)aCallSite context:(KWContextNode *)context description:(NSString *)aDescription { 31 | return [[self alloc] initWithCallSite:aCallSite context:context description:aDescription]; 32 | } 33 | 34 | #pragma mark - Accepting Visitors 35 | 36 | - (void)acceptExampleNodeVisitor:(id)aVisitor { 37 | [aVisitor visitPendingNode:self]; 38 | } 39 | 40 | #pragma mark - Accessing the context stack 41 | 42 | - (NSArray *)contextStack 43 | { 44 | NSMutableArray *contextStack = [NSMutableArray array]; 45 | 46 | KWContextNode *currentContext = _context; 47 | 48 | while (currentContext) { 49 | [contextStack addObject:currentContext]; 50 | currentContext = currentContext.parentContext; 51 | } 52 | return contextStack; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWRegisterMatchersNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWExampleNode.h" 9 | 10 | @class KWCallSite; 11 | 12 | @interface KWRegisterMatchersNode : NSObject 13 | 14 | #pragma mark - Initializing 15 | 16 | - (id)initWithCallSite:(KWCallSite *)aCallSite namespacePrefix:(NSString *)aNamespacePrefix; 17 | 18 | + (id)registerMatchersNodeWithCallSite:(KWCallSite *)aCallSite namespacePrefix:(NSString *)aNamespacePrefix; 19 | 20 | #pragma mark - Getting Call Sites 21 | 22 | @property (nonatomic, readonly) KWCallSite *callSite; 23 | 24 | #pragma mark - Getting Namespace Prefixes 25 | 26 | @property (nonatomic, readonly) NSString *namespacePrefix; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Nodes/KWRegisterMatchersNode.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWRegisterMatchersNode.h" 8 | 9 | #import "KWCallSite.h" 10 | #import "KWExampleNodeVisitor.h" 11 | 12 | @implementation KWRegisterMatchersNode 13 | 14 | #pragma mark - Initializing 15 | 16 | - (id)initWithCallSite:(KWCallSite *)aCallSite namespacePrefix:(NSString *)aNamespacePrefix { 17 | self = [super init]; 18 | if (self) { 19 | _callSite = aCallSite; 20 | _namespacePrefix = [aNamespacePrefix copy]; 21 | } 22 | 23 | return self; 24 | } 25 | 26 | + (id)registerMatchersNodeWithCallSite:(KWCallSite *)aCallSite namespacePrefix:(NSString *)aNamespacePrefix { 27 | return [[self alloc] initWithCallSite:aCallSite namespacePrefix:aNamespacePrefix]; 28 | } 29 | 30 | #pragma mark - Accepting Visitors 31 | 32 | - (void)acceptExampleNodeVisitor:(id)aVisitor { 33 | [aVisitor visitRegisterMatchersNode:self]; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Shared Examples/KWSharedExample.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2014 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | typedef void (^KWSharedExampleBlock)(NSDictionary *data); 10 | 11 | @interface KWSharedExample : NSObject 12 | 13 | @property (nonatomic, copy) NSString *name; 14 | @property (nonatomic, copy) KWSharedExampleBlock block; 15 | 16 | - (id)initWithName:(NSString *)name block:(KWSharedExampleBlock)block; 17 | 18 | @end 19 | 20 | #pragma mark - Building Shared Example Groups 21 | 22 | void sharedExamplesFor(NSString *name, KWSharedExampleBlock block); 23 | void itBehavesLike(NSString *name, NSDictionary *data); 24 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Shared Examples/KWSharedExample.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2014 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWSharedExample.h" 8 | #import "KWSharedExampleRegistry.h" 9 | #import "KWExample.h" 10 | 11 | @implementation KWSharedExample 12 | 13 | #pragma mark - Initializing 14 | 15 | - (id)initWithName:(NSString *)name block:(KWSharedExampleBlock)block { 16 | NSParameterAssert(name); 17 | NSParameterAssert(block); 18 | 19 | self = [super init]; 20 | if (self) { 21 | _name = name; 22 | _block = block; 23 | } 24 | return self; 25 | } 26 | 27 | @end 28 | 29 | #pragma mark - Building Example Groups 30 | 31 | void sharedExamplesFor(NSString *name, KWSharedExampleBlock block) { 32 | KWSharedExample *sharedExample = [[KWSharedExample alloc] initWithName:name block:block]; 33 | [[KWSharedExampleRegistry sharedRegistry] registerSharedExample:sharedExample]; 34 | } 35 | 36 | void itBehavesLike(NSString *name, NSDictionary *data) { 37 | KWSharedExample *sharedExample = [[KWSharedExampleRegistry sharedRegistry] sharedExampleForName:name]; 38 | NSString *description = [NSString stringWithFormat:@"behaves like %@", sharedExample.name]; 39 | context(description, ^{ sharedExample.block(data); }); 40 | } 41 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Shared Examples/KWSharedExampleRegistry.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2014 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | @class KWSharedExample; 10 | 11 | @interface KWSharedExampleRegistry : NSObject 12 | 13 | + (instancetype)sharedRegistry; 14 | - (KWSharedExample *)sharedExampleForName:(NSString *)name; 15 | - (void)registerSharedExample:(KWSharedExample *)sharedExample; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Shared Examples/KWSharedExampleRegistry.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2014 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWSharedExampleRegistry.h" 8 | #import "KWSharedExample.h" 9 | 10 | @interface KWSharedExampleRegistry () 11 | @property (nonatomic, strong) NSMutableDictionary *sharedExamples; 12 | @end 13 | 14 | @implementation KWSharedExampleRegistry 15 | 16 | #pragma mark - Initializing 17 | 18 | + (instancetype)sharedRegistry { 19 | static KWSharedExampleRegistry *sharedRegistry = nil; 20 | static dispatch_once_t onceToken; 21 | dispatch_once(&onceToken, ^{ 22 | sharedRegistry = [self new]; 23 | 24 | }); 25 | return sharedRegistry; 26 | } 27 | 28 | - (id)init { 29 | self = [super init]; 30 | if (self) { 31 | _sharedExamples = [NSMutableDictionary dictionary]; 32 | } 33 | return self; 34 | } 35 | 36 | #pragma mark - Public Interface 37 | 38 | - (KWSharedExample *)sharedExampleForName:(NSString *)name { 39 | [self raiseIfSharedExampleNotRegistered:name]; 40 | return [_sharedExamples objectForKey:name]; 41 | } 42 | 43 | - (void)registerSharedExample:(KWSharedExample *)sharedExample { 44 | [self raiseIfSharedExampleAlreadyRegistered:sharedExample]; 45 | [_sharedExamples setObject:sharedExample forKey:sharedExample.name]; 46 | } 47 | 48 | #pragma mark - Internal Methods 49 | 50 | - (void)raiseIfSharedExampleNotRegistered:(NSString *)name { 51 | if (![_sharedExamples objectForKey:name]) { 52 | [NSException raise:NSInternalInconsistencyException 53 | format:@"Kiwi shared example error: No shared example registered for '%@'", 54 | name]; 55 | } 56 | } 57 | 58 | - (void)raiseIfSharedExampleAlreadyRegistered:(KWSharedExample *)sharedExample { 59 | if ([_sharedExamples objectForKey:sharedExample.name]) { 60 | [NSException raise:NSInternalInconsistencyException 61 | format:@"Kiwi shared example error: Shared example already registered for '%@'", 62 | sharedExample.name]; 63 | } 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Stubbing/KWIntercept.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import 9 | 10 | @class KWMessagePattern; 11 | @class KWStub; 12 | 13 | #pragma mark - Getting Forwarding Implementations 14 | 15 | IMP KWRegularForwardingImplementation(void); 16 | IMP KWStretForwardingImplementation(void); 17 | IMP KWForwardingImplementationForMethodEncoding(const char* encoding); 18 | 19 | #pragma mark - Getting Intercept Class Information 20 | 21 | BOOL KWObjectIsClass(id anObject); 22 | BOOL KWClassIsInterceptClass(Class aClass); 23 | NSString *KWInterceptClassNameForClass(Class aClass); 24 | Class KWInterceptClassForCanonicalClass(Class canonicalClass); 25 | Class KWRealClassForClass(Class aClass); 26 | 27 | #pragma mark - Enabling Intercepting 28 | 29 | Class KWSetupObjectInterceptSupport(id anObject); 30 | void KWSetupMethodInterceptSupport(Class interceptClass, SEL aSelector); 31 | 32 | #pragma mark - Managing Stubs & Spies 33 | void KWClearStubsAndSpies(void); 34 | 35 | #pragma mark - Managing Objects Stubs 36 | 37 | void KWAssociateObjectStub(id anObject, KWStub *aStub, BOOL overrideExisting); 38 | void KWClearObjectStubs(id anObject); 39 | void KWClearAllObjectStubs(void); 40 | 41 | #pragma mark - Managing Message Spies 42 | 43 | void KWAssociateMessageSpy(id anObject, id aSpy, KWMessagePattern *aMessagePattern); 44 | void KWClearObjectSpy(id anObject, id aSpy, KWMessagePattern *aMessagePattern); 45 | void KWClearAllMessageSpies(void); 46 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Stubbing/KWStub.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @class KWMessagePattern; 10 | 11 | @interface KWStub : NSObject 12 | 13 | #pragma mark - Initializing 14 | 15 | - (id)initWithMessagePattern:(KWMessagePattern *)aMessagePattern; 16 | - (id)initWithMessagePattern:(KWMessagePattern *)aMessagePattern value:(id)aValue; 17 | - (id)initWithMessagePattern:(KWMessagePattern *)aMessagePattern block:(id (^)(NSArray *params))aBlock; 18 | - (id)initWithMessagePattern:(KWMessagePattern *)aMessagePattern value:(id)aValue times:(id)times afterThatReturn:(id)aSecondValue; 19 | 20 | + (id)stubWithMessagePattern:(KWMessagePattern *)aMessagePattern; 21 | + (id)stubWithMessagePattern:(KWMessagePattern *)aMessagePattern value:(id)aValue; 22 | + (id)stubWithMessagePattern:(KWMessagePattern *)aMessagePattern block:(id (^)(NSArray *params))aBlock; 23 | + (id)stubWithMessagePattern:(KWMessagePattern *)aMessagePattern value:(id)aValue times:(id)times afterThatReturn:(id)aSecondValue; 24 | 25 | #pragma mark - Properties 26 | 27 | @property (nonatomic, readonly) KWMessagePattern *messagePattern; 28 | @property (nonatomic, readonly) id value; 29 | @property (nonatomic, readonly) id returnValueTimes; 30 | @property (nonatomic, readonly) int returnedValueTimes; 31 | @property (nonatomic, readonly) id secondValue; 32 | 33 | #pragma mark - Processing Invocations 34 | 35 | - (BOOL)processInvocation:(NSInvocation *)anInvocation; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Stubbing/NSObject+KiwiStubAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @class KWCaptureSpy; 10 | @class KWMessagePattern; 11 | 12 | @protocol KWMessageSpying; 13 | 14 | @protocol KiwiStubAdditions 15 | 16 | #pragma mark - Stubbing Methods 17 | 18 | - (void)stub:(SEL)aSelector; 19 | - (void)stub:(SEL)aSelector withBlock:(id (^)(NSArray *params))block; 20 | - (void)stub:(SEL)aSelector withArguments:(id)firstArgument, ...; 21 | - (void)stub:(SEL)aSelector andReturn:(id)aValue; 22 | - (void)stub:(SEL)aSelector andReturn:(id)aValue withArguments:(id)firstArgument, ...; 23 | - (void)stub:(SEL)aSelector andReturn:(id)aValue times:(NSNumber *)times afterThatReturn:(id)aSecondValue; 24 | 25 | + (void)stub:(SEL)aSelector; 26 | + (void)stub:(SEL)aSelector withBlock:(id (^)(NSArray *params))block; 27 | + (void)stub:(SEL)aSelector withArguments:(id)firstArgument, ...; 28 | + (void)stub:(SEL)aSelector andReturn:(id)aValue; 29 | + (void)stub:(SEL)aSelector andReturn:(id)aValue withArguments:(id)firstArgument, ...; 30 | + (void)stub:(SEL)aSelector andReturn:(id)aValue times:(NSNumber *)times afterThatReturn:(id)aSecondValue; 31 | 32 | - (id)stub DEPRECATED_ATTRIBUTE; 33 | - (id)stubAndReturn:(id)aValue DEPRECATED_ATTRIBUTE; 34 | - (id)stubAndReturn:(id)aValue times:(id)times afterThatReturn:(id)aSecondValue DEPRECATED_ATTRIBUTE; 35 | 36 | // These methods will become private 37 | - (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue; 38 | - (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue overrideExisting:(BOOL)overrideExisting; 39 | - (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue times:(id)times afterThatReturn:(id)aSecondValue; 40 | - (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern withBlock:(id (^)(NSArray *params))block; 41 | 42 | // These methods will become private 43 | + (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue; 44 | + (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue times:(id)times afterThatReturn:(id)aSecondValue; 45 | + (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern withBlock:(id (^)(NSArray *params))block; 46 | 47 | - (void)clearStubs; 48 | 49 | #pragma mark - Spying on Messages 50 | 51 | - (void)addMessageSpy:(id)aSpy forMessagePattern:(KWMessagePattern *)aMessagePattern; 52 | - (void)removeMessageSpy:(id)aSpy forMessagePattern:(KWMessagePattern *)aMessagePattern; 53 | - (KWCaptureSpy *)captureArgument:(SEL)selector atIndex:(NSUInteger)index; 54 | 55 | + (void)addMessageSpy:(id)aSpy forMessagePattern:(KWMessagePattern *)aMessagePattern; 56 | + (void)removeMessageSpy:(id)aSpy forMessagePattern:(KWMessagePattern *)aMessagePattern; 57 | + (KWCaptureSpy *)captureArgument:(SEL)selector atIndex:(NSUInteger)index; 58 | 59 | @end 60 | 61 | @interface NSObject(KiwiStubAdditions) 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Verifiers/KWAsyncVerifier.h: -------------------------------------------------------------------------------- 1 | // 2 | // KWAsyncVerifier.h 3 | // iOSFalconCore 4 | // 5 | // Created by Luke Redpath on 13/01/2011. 6 | // Copyright 2011 LJR Software Limited. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KWMatchVerifier.h" 11 | #import "KWProbe.h" 12 | 13 | #define kKW_DEFAULT_PROBE_TIMEOUT 1.0 14 | 15 | @class KWAsyncMatcherProbe; 16 | 17 | @interface KWAsyncVerifier : KWMatchVerifier 18 | 19 | @property (nonatomic, assign) NSTimeInterval timeout; 20 | @property (nonatomic, assign) BOOL shouldWait; 21 | 22 | + (id)asyncVerifierWithExpectationType:(KWExpectationType)anExpectationType callSite:(KWCallSite *)aCallSite matcherFactory:(KWMatcherFactory *)aMatcherFactory reporter:(id)aReporter probeTimeout:(NSTimeInterval)probeTimeout shouldWait:(BOOL)shouldWait; 23 | - (void)verifyWithProbe:(KWAsyncMatcherProbe *)aProbe; 24 | 25 | @end 26 | 27 | 28 | @interface KWAsyncMatcherProbe : NSObject 29 | 30 | @property (nonatomic, assign) BOOL matchResult; 31 | @property (nonatomic, readonly) id matcher; 32 | 33 | - (id)initWithMatcher:(id)aMatcher; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Verifiers/KWExistVerifier.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWExpectationType.h" 9 | #import "KWVerifying.h" 10 | 11 | @class KWCallSite; 12 | 13 | @protocol KWReporting; 14 | 15 | @interface KWExistVerifier : NSObject 16 | 17 | #pragma mark - Initializing 18 | 19 | - (id)initWithExpectationType:(KWExpectationType)anExpectationType callSite:(KWCallSite *)aCallSite reporter:(id)aReporter; 20 | 21 | + (id)existVerifierWithExpectationType:(KWExpectationType)anExpectationType callSite:(KWCallSite *)aCallSite reporter:(id)aReporter; 22 | 23 | #pragma mark - Properties 24 | 25 | @property (nonatomic, strong) id subject; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Verifiers/KWExistVerifier.m: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KWExistVerifier.h" 8 | 9 | #import "KWCallSite.h" 10 | #import "KWFailure.h" 11 | #import "KWFormatter.h" 12 | #import "KWReporting.h" 13 | 14 | @interface KWExistVerifier() 15 | 16 | @property (nonatomic, readonly) KWExpectationType expectationType; 17 | @property (nonatomic, readonly) id reporter; 18 | 19 | @property (nonatomic, strong) KWCallSite *callSite; 20 | 21 | @end 22 | 23 | @implementation KWExistVerifier 24 | 25 | #pragma mark - Initializing 26 | 27 | - (id)initWithExpectationType:(KWExpectationType)anExpectationType callSite:(KWCallSite *)aCallSite reporter:(id)aReporter { 28 | self = [super init]; 29 | if (self) { 30 | _expectationType = anExpectationType; 31 | _callSite = aCallSite; 32 | _reporter = aReporter; 33 | } 34 | 35 | return self; 36 | } 37 | 38 | + (id)existVerifierWithExpectationType:(KWExpectationType)anExpectationType callSite:(KWCallSite *)aCallSite reporter:(id)aReporter { 39 | return [[self alloc] initWithExpectationType:anExpectationType callSite:aCallSite reporter:aReporter]; 40 | } 41 | 42 | 43 | - (NSString *)descriptionForAnonymousItNode { 44 | if (self.expectationType == KWExpectationTypeShould) { 45 | return @"should exist"; 46 | } 47 | return @"should not exist"; 48 | } 49 | 50 | #pragma mark - Ending Examples 51 | 52 | - (void)exampleWillEnd { 53 | if (self.expectationType == KWExpectationTypeShould && self.subject == nil) { 54 | KWFailure *failure = [KWFailure failureWithCallSite:self.callSite message:@"expected subject not to be nil"]; 55 | [self.reporter reportFailure:failure]; 56 | } else if (self.expectationType == KWExpectationTypeShouldNot && self.subject != nil) { 57 | KWFailure *failure = [KWFailure failureWithCallSite:self.callSite format:@"expected subject to be nil, got %@", 58 | [KWFormatter formatObject:self.subject]]; 59 | [self.reporter reportFailure:failure]; 60 | } 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Verifiers/KWMatchVerifier.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | #import "KWExpectationType.h" 9 | #import "KWVerifying.h" 10 | 11 | @class KWCallSite; 12 | @class KWMatcherFactory; 13 | 14 | @protocol KWMatching; 15 | @protocol KWReporting; 16 | 17 | @interface KWMatchVerifier : NSObject 18 | 19 | #pragma mark - Properties 20 | 21 | @property (nonatomic, readonly) KWExpectationType expectationType; 22 | 23 | @property (nonatomic, readonly) KWMatcherFactory *matcherFactory; 24 | @property (nonatomic, readonly) id reporter; 25 | 26 | @property (nonatomic, strong) id subject; 27 | 28 | 29 | #pragma mark - Initializing 30 | 31 | - (id)initForShouldWithCallSite:(KWCallSite *)aCallSite matcherFactory:(KWMatcherFactory *)aMatcherFactory reporter:(id)aReporter; 32 | - (id)initForShouldNotWithCallSite:(KWCallSite *)aCallSite matcherFactory:(KWMatcherFactory *)aMatcherFactory reporter:(id)aReporter; 33 | - (id)initWithExpectationType:(KWExpectationType)anExpectationType callSite:(KWCallSite *)aCallSite matcherFactory:(KWMatcherFactory *)aMatcherFactory reporter:(id)aReporter; 34 | 35 | + (id)matchVerifierWithExpectationType:(KWExpectationType)anExpectationType callSite:(KWCallSite *)aCallSite matcherFactory:(KWMatcherFactory *)aMatcherFactory reporter:(id)aReporter; 36 | 37 | - (void)verifyWithMatcher:(id)aMatcher; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Classes/Verifiers/KWVerifying.h: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the terms in License.txt 3 | // 4 | // Copyright 2010 Allen Ding. All rights reserved. 5 | // 6 | 7 | #import "KiwiConfiguration.h" 8 | 9 | @class KWCallSite; 10 | 11 | @protocol KWVerifying 12 | 13 | @property (nonatomic, readonly) KWCallSite *callSite; 14 | 15 | - (NSString *)descriptionForAnonymousItNode; 16 | 17 | #pragma mark - Subjects 18 | 19 | @property (nonatomic, strong) id subject; 20 | 21 | #pragma mark - Ending Examples 22 | 23 | - (void)exampleWillEnd; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/License.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, Allen Ding 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | 3. Neither the name of Allen Ding nor the names of any contributors may be 15 | used to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /Example/Pods/Kiwi/Readme.md: -------------------------------------------------------------------------------- 1 | ![Kiwi Logo](Kiwi-Logo.png) 2 | 3 | # Kiwi: Simple BDD for iOS 4 | [![Build Status](https://travis-ci.org/kiwi-bdd/Kiwi.svg?branch=master)](https://travis-ci.org/kiwi-bdd/Kiwi) 5 | 6 | Kiwi is a Behavior Driven Development library for iOS development. 7 | The goal is to provide a BDD library that is exquisitely simple to setup and use. 8 | 9 | ## Why? 10 | The idea behind Kiwi is to have tests that are more readable than what is possible with the bundled test framework. 11 | 12 | Tests (or rather specs) are written in Objective-C and run within the comfort of Xcode to provide a test environment that is as unobtrusive and seamless as possible in terms of running tests and error reporting. 13 | 14 | Specs look like this: 15 | 16 | ```objective-c 17 | describe(@"Team", ^{ 18 | context(@"when newly created", ^{ 19 | it(@"has a name", ^{ 20 | id team = [Team team]; 21 | [[team.name should] equal:@"Black Hawks"]; 22 | }); 23 | 24 | it(@"has 11 players", ^{ 25 | id team = [Team team]; 26 | [[[team should] have:11] players]; 27 | }); 28 | }); 29 | }); 30 | ``` 31 | 32 | ## Documentation 33 | The [Kiwi Wiki](https://github.com/kiwi-bdd/Kiwi/wiki) is the official documentation source. 34 | 35 | ## Getting it 36 | 37 | #### 38 | To install via [CocoaPods](https://github.com/cocoapods/cocoapods), add this to your `Podfile`: 39 | 40 | ```ruby 41 | pod "Kiwi" 42 | ``` 43 | 44 | Or via [Carthage](https://github.com/Carthage/Carthage), add this to `Cartfile.private`: 45 | 46 | ``` 47 | github "kiwi-bdd/Kiwi" 48 | ``` 49 | 50 | ## Support 51 | For all the questions / suggestions you have, that aren't bug reports please use our [Google Group](https://groups.google.com/forum/#!forum/kiwi-bdd) 52 | 53 | -------------------------------------------------------------------------------- /Example/Pods/Local Podspecs/FMDBHelper.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "FMDBHelper", 3 | "version": "1.1.0", 4 | "summary": "Easier to use FMDB, support ORM and JSON into the model class.", 5 | "homepage": "http://lijingcheng.github.io/", 6 | "license": "MIT", 7 | "authors": { 8 | "lijingcheng": "bj_lijingcheng@163.com" 9 | }, 10 | "source": { 11 | "git": "https://github.com/lijingcheng/FMDBHelper.git", 12 | "tag": "1.1.0" 13 | }, 14 | "social_media_url": "http://weibo.com/lijingcheng1984", 15 | "source_files": "FMDBHelper/Classes/*.{h,m}", 16 | "platforms": { 17 | "ios": "9.0" 18 | }, 19 | "dependencies": { 20 | "FMDB": [ 21 | "2.7.5" 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Example/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - FMDB (2.7.5): 3 | - FMDB/standard (= 2.7.5) 4 | - FMDB/standard (2.7.5) 5 | - FMDBHelper (1.1.0): 6 | - FMDB (= 2.7.5) 7 | - Kiwi (3.0.0) 8 | 9 | DEPENDENCIES: 10 | - FMDBHelper (from `../`) 11 | - Kiwi (= 3.0.0) 12 | 13 | SPEC REPOS: 14 | https://github.com/cocoapods/specs.git: 15 | - FMDB 16 | - Kiwi 17 | 18 | EXTERNAL SOURCES: 19 | FMDBHelper: 20 | :path: "../" 21 | 22 | SPEC CHECKSUMS: 23 | FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a 24 | FMDBHelper: 6fb8cf752838b308876ef989603e48442ecd4c37 25 | Kiwi: fbeafef0f00e4d8f7dcb3420a4930afe70af77f7 26 | 27 | PODFILE CHECKSUM: 6f6a1127fb3749b24238e061a948978f12a6e8c3 28 | 29 | COCOAPODS: 1.5.3 30 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/FMDB/FMDB-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_FMDB : NSObject 3 | @end 4 | @implementation PodsDummy_FMDB 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/FMDB/FMDB-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/FMDB/FMDB.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/FMDB 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/FMDB" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/FMDB" 4 | OTHER_LDFLAGS = -l"sqlite3" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/FMDB 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/FMDBHelper/FMDBHelper-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_FMDBHelper : NSObject 3 | @end 4 | @implementation PodsDummy_FMDBHelper 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/FMDBHelper/FMDBHelper-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/FMDBHelper/FMDBHelper.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/FMDBHelper 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/FMDBHelper" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/FMDB" "${PODS_ROOT}/Headers/Public/FMDBHelper" 4 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/FMDB" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../.. 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Kiwi/Kiwi-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Kiwi : NSObject 3 | @end 4 | @implementation PodsDummy_Kiwi 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Kiwi/Kiwi-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import 14 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Kiwi/Kiwi.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Kiwi 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Kiwi" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Kiwi" 5 | OTHER_LDFLAGS = -framework "XCTest" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT} 9 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Kiwi 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-FMDBHelper_Tests/Pods-FMDBHelper_Tests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_FMDBHelper_Tests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_FMDBHelper_Tests 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-FMDBHelper_Tests/Pods-FMDBHelper_Tests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/FMDB" "${PODS_ROOT}/Headers/Public/FMDBHelper" "${PODS_ROOT}/Headers/Public/Kiwi" 4 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/FMDB" "${PODS_CONFIGURATION_BUILD_DIR}/FMDBHelper" "${PODS_CONFIGURATION_BUILD_DIR}/Kiwi" 5 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/FMDB" -isystem "${PODS_ROOT}/Headers/Public/FMDBHelper" -isystem "${PODS_ROOT}/Headers/Public/Kiwi" 6 | OTHER_LDFLAGS = $(inherited) -ObjC -l"FMDB" -l"FMDBHelper" -l"Kiwi" -l"sqlite3" -framework "XCTest" 7 | PODS_BUILD_DIR = ${BUILD_DIR} 8 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 9 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 10 | PODS_ROOT = ${SRCROOT}/Pods 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-FMDBHelper_Tests/Pods-FMDBHelper_Tests.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/FMDB" "${PODS_ROOT}/Headers/Public/FMDBHelper" "${PODS_ROOT}/Headers/Public/Kiwi" 4 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/FMDB" "${PODS_CONFIGURATION_BUILD_DIR}/FMDBHelper" "${PODS_CONFIGURATION_BUILD_DIR}/Kiwi" 5 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/FMDB" -isystem "${PODS_ROOT}/Headers/Public/FMDBHelper" -isystem "${PODS_ROOT}/Headers/Public/Kiwi" 6 | OTHER_LDFLAGS = $(inherited) -ObjC -l"FMDB" -l"FMDBHelper" -l"Kiwi" -l"sqlite3" -framework "XCTest" 7 | PODS_BUILD_DIR = ${BUILD_DIR} 8 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 9 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 10 | PODS_ROOT = ${SRCROOT}/Pods 11 | -------------------------------------------------------------------------------- /Example/Tests/Dept.h: -------------------------------------------------------------------------------- 1 | // 2 | // Dept.h 3 | // FMDBHelper 4 | // 5 | // Created by 李京城 on 15/5/2. 6 | // Copyright (c) 2015年 李京城. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Dept : NSObject 12 | 13 | @property (nonatomic, copy) NSString *name; 14 | @property (nonatomic, copy) NSString *manager; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/Tests/Dept.m: -------------------------------------------------------------------------------- 1 | // 2 | // Dept.m 3 | // FMDBHelper 4 | // 5 | // Created by 李京城 on 15/5/2. 6 | // Copyright (c) 2015年 李京城. All rights reserved. 7 | // 8 | 9 | #import "Dept.h" 10 | 11 | @implementation Dept 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/Tests/Dog.h: -------------------------------------------------------------------------------- 1 | // 2 | // Dog.h 3 | // FMDBHelper 4 | // 5 | // Created by 李京城 on 16/8/30. 6 | // Copyright © 2016年 lijingcheng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Dog : NSObject 12 | 13 | @property (nonatomic, copy) NSString *name; 14 | @property (nonatomic, assign) NSInteger age; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/Tests/Dog.m: -------------------------------------------------------------------------------- 1 | // 2 | // Dog.m 3 | // FMDBHelper 4 | // 5 | // Created by 李京城 on 16/8/30. 6 | // Copyright © 2016年 lijingcheng. All rights reserved. 7 | // 8 | 9 | #import "Dog.h" 10 | 11 | @implementation Dog 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/Tests/Tests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/Tests/Tests-Prefix.pch: -------------------------------------------------------------------------------- 1 | // The contents of this file are implicitly included at the beginning of every test case source file. 2 | 3 | #ifdef __OBJC__ 4 | 5 | #endif 6 | -------------------------------------------------------------------------------- /Example/Tests/User.h: -------------------------------------------------------------------------------- 1 | // 2 | // User.h 3 | // FMDBHelper 4 | // 5 | // Created by 李京城 on 15/5/2. 6 | // Copyright (c) 2015年 李京城. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class Dog; 12 | @class Dept; 13 | @interface User : NSObject 14 | 15 | @property (nonatomic, copy) NSString *name; 16 | @property (nonatomic, assign) NSInteger age; 17 | @property (nonatomic, copy) NSString *birthday; 18 | @property (nonatomic, strong) Dept *dept; 19 | @property (nonatomic, copy) NSArray *dogs; 20 | @property (nonatomic, copy) NSArray *nums; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Example/Tests/User.m: -------------------------------------------------------------------------------- 1 | // 2 | // User.m 3 | // FMDBHelper 4 | // 5 | // Created by 李京城 on 15/5/2. 6 | // Copyright (c) 2015年 李京城. All rights reserved. 7 | // 8 | 9 | #import "User.h" 10 | #import "Dept.h" 11 | #import "Dog.h" 12 | 13 | @implementation User 14 | 15 | - (NSDictionary *)mapping { 16 | return @{@"username": @"name"}; 17 | } 18 | 19 | - (NSDictionary *)objectPropertys { 20 | return @{@"dept": [Dept class]}; 21 | } 22 | 23 | - (NSDictionary *)genericForArray { 24 | return @{@"dogs": [Dog class]}; 25 | } 26 | 27 | + (NSString *)tableName { 28 | return @"sys_user"; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Example/Tests/demo.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "a1b2c3d4e5", 3 | "username": "李京城", 4 | "age": 18, 5 | "birthday": "1984/3/28", 6 | "dept":{ 7 | "id": "f6g7h8i9j0", 8 | "name": "dev", 9 | "manager": "X" 10 | }, 11 | "dogs":[ 12 | { 13 | "id": "0x0x0x0x", 14 | "name": "ahuang", 15 | "age": "15" 16 | }, 17 | { 18 | "id": "1x1x1x1x", 19 | "name": "xhei", 20 | "age": "6" 21 | } 22 | ], 23 | "nums":[ 24 | 123, 25 | 234 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /Example/Tests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /FMDBHelper.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint FMDBHelper.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = 'FMDBHelper' 11 | s.version = '1.1.0' 12 | s.summary = 'Easier to use FMDB, support ORM and JSON into the model class.' 13 | s.homepage = 'http://lijingcheng.github.io/' 14 | s.license = 'MIT' 15 | s.author = { 'lijingcheng' => 'bj_lijingcheng@163.com' } 16 | s.source = { :git => 'https://github.com/lijingcheng/FMDBHelper.git', :tag => s.version.to_s } 17 | s.social_media_url = 'http://weibo.com/lijingcheng1984' 18 | s.source_files = 'FMDBHelper/Classes/*.{h,m}' 19 | s.platform = :ios, '9.0' 20 | s.dependency 'FMDB', '2.7.5' 21 | end 22 | -------------------------------------------------------------------------------- /FMDBHelper/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lijingcheng/FMDBHelper/80b4741ca8268df4f98a60f73036296f3a0b5cdf/FMDBHelper/Assets/.gitkeep -------------------------------------------------------------------------------- /FMDBHelper/Classes/FMDBHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // FMDBHelper.h 3 | // FMDBHelper 4 | // 5 | // Created by 李京城 on 15/3/10. 6 | // Copyright (c) 2015年 李京城. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FMDBHelper : NSObject 12 | 13 | /** 14 | * Setting up the database file name 15 | */ 16 | + (void)setDataBaseName:(NSString *)name; 17 | 18 | /** 19 | * Setting up the database file path 20 | */ 21 | 22 | + (void)setDataBasePath:(NSString *)path; 23 | 24 | /** 25 | * Use @sql create 26 | */ 27 | + (BOOL)createTable:(NSString *)sql; 28 | 29 | /** 30 | * Drop table use tableName 31 | */ 32 | + (BOOL)dropTable:(NSString *)tableName; 33 | 34 | /** 35 | * Use @sql insert 36 | */ 37 | + (BOOL)insert:(NSString *)sql; 38 | 39 | /** 40 | * Use @obj insert 41 | */ 42 | + (BOOL)insertObject:(NSObject *)obj; 43 | 44 | /** 45 | * Insert or replace @keyValues into @table 46 | */ 47 | + (BOOL)insert:(NSString *)table keyValues:(NSDictionary *)keyValues; 48 | 49 | /** 50 | * Insert @keyValues into @table 51 | * 52 | * @param replace if have is the same record, whether you need to replace 53 | */ 54 | + (BOOL)insert:(NSString *)table keyValues:(NSDictionary *)keyValues replace:(BOOL)replace; 55 | 56 | /** 57 | * Use @sql Update 58 | */ 59 | + (BOOL)update:(NSString *)sql; 60 | 61 | /** 62 | * Use @obj Update 63 | */ 64 | + (BOOL)updateObject:(NSObject *)obj; 65 | 66 | /** 67 | * Use @keyValues updated @table 68 | * 69 | * @warning the default where is "id=?", so @keyValues must include "id" 70 | */ 71 | + (BOOL)update:(NSString *)table keyValues:(NSDictionary *)keyValues; 72 | 73 | /** 74 | * If the @where are met, use @keyValues updated @table 75 | */ 76 | + (BOOL)update:(NSString *)table keyValues:(NSDictionary *)keyValues where:(NSString *)where; 77 | 78 | /** 79 | * Delete from @table 80 | */ 81 | + (BOOL)remove:(NSString *)table; 82 | 83 | /** 84 | * Use @obj delete 85 | */ 86 | + (BOOL)removeObject:(NSObject *)obj; 87 | 88 | /** 89 | * Delete from @table where id=@id_ 90 | */ 91 | + (BOOL)removeById:(NSString *)id_ from:(NSString *)table; 92 | 93 | /** 94 | * Delete from @table @where 95 | */ 96 | + (BOOL)remove:(NSString *)table where:(NSString *)where; 97 | 98 | /** 99 | * Select * from @table 100 | */ 101 | + (NSMutableArray *)query:(NSString *)table; 102 | 103 | /** 104 | * Select * from @table where id=@id_ 105 | */ 106 | + (NSDictionary *)queryById:(NSString *)id_ from:(NSString *)table; 107 | 108 | /** 109 | * Select * from @table @where 110 | */ 111 | + (NSMutableArray *)query:(NSString *)table where:(NSString *)where, ... NS_REQUIRES_NIL_TERMINATION; 112 | 113 | /** 114 | * Select count(id) from @table 115 | */ 116 | + (NSInteger)totalRowOfTable:(NSString *)table; 117 | 118 | /** 119 | * Select count(id) from @table @where 120 | */ 121 | + (NSInteger)totalRowOfTable:(NSString *)table where:(NSString *)where; 122 | 123 | /** 124 | * batch execute @sqls 125 | * 126 | * @param useTransaction whether to use transaction 127 | */ 128 | + (BOOL)executeBatch:(NSArray *)sqls useTransaction:(BOOL)useTransaction; 129 | 130 | @end 131 | -------------------------------------------------------------------------------- /FMDBHelper/Classes/NSObject+JCAdditionsORM.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+JCAdditionsORM.h 3 | // FMDBHelper 4 | // 5 | // Created by 李京城 on 15/4/27. 6 | // Copyright (c) 2015年 李京城. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | extern NSString * const identifier; 12 | 13 | @interface NSObject (JCAdditionsORM) 14 | 15 | /** 16 | * For the corresponding database table primary key id 17 | */ 18 | @property (nonatomic, copy) NSString *ID; 19 | 20 | /** 21 | * Properties and corresponding values 22 | */ 23 | @property (nonatomic, readonly) NSMutableDictionary *keyValues; 24 | 25 | /** 26 | * The key is the best as the property name,if not. @see mapping 27 | */ 28 | - (instancetype)initWithDictionary:(NSDictionary *)keyValues; 29 | 30 | /** 31 | * If the property type is a custom class, you need to overwrite this method. 32 | * 33 | * @return key is property name, value is model class, default return @{}; 34 | */ 35 | - (NSDictionary *)objectPropertys; 36 | 37 | /* 38 | * If the property type is a NSArray<...>, and property type is a custom class, you need to overwrite this method. 39 | * 40 | * @return key is property name, value is generic, default return @{}; 41 | */ 42 | - (NSDictionary *)genericForArray; 43 | 44 | /** 45 | * If the property name and the JSON keys is not the same key, you need to overwrite this method. 46 | * 47 | * @return key is datasource's key, value is property name, default return @{}. 48 | */ 49 | - (NSDictionary *)mapping; 50 | 51 | /** 52 | * If the model class name and the table name is different, you need to overwrite this method. 53 | * 54 | * @return default return the class name. 55 | */ 56 | + (NSString *)tableName; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 lijingcheng 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lijingcheng/FMDBHelper/80b4741ca8268df4f98a60f73036296f3a0b5cdf/logo.png -------------------------------------------------------------------------------- /performance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lijingcheng/FMDBHelper/80b4741ca8268df4f98a60f73036296f3a0b5cdf/performance.png --------------------------------------------------------------------------------