├── .DS_Store ├── .gitignore ├── DependencyInjectionExample.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── DependencyInjectionExample ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Bob.imageset │ │ ├── Bob@2x.png │ │ └── Contents.json │ └── Dave.imageset │ │ ├── Contents.json │ │ └── Dave@2x.png ├── Info.plist ├── Minion.swift ├── MinionService.swift └── ViewController.swift ├── DependencyInjectionExampleQuickTests ├── Info.plist └── ViewControllerSpec.swift ├── DependencyInjectionExampleTests ├── Info.plist └── ViewControllerTests.swift ├── README.md └── Vendor ├── Nimble ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE.md ├── Nimble.podspec ├── Nimble.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ ├── Nimble-OSX.xcscheme │ │ └── Nimble-iOS.xcscheme ├── Nimble │ ├── Adapters │ │ ├── AdapterProtocols.swift │ │ ├── AssertionRecorder.swift │ │ └── XCTestHandler.swift │ ├── DSL+Wait.swift │ ├── DSL.swift │ ├── Expectation.swift │ ├── Expression.swift │ ├── FailureMessage.swift │ ├── Info.plist │ ├── Matchers │ │ ├── BeAKindOf.swift │ │ ├── BeAnInstanceOf.swift │ │ ├── BeCloseTo.swift │ │ ├── BeEmpty.swift │ │ ├── BeGreaterThan.swift │ │ ├── BeGreaterThanOrEqualTo.swift │ │ ├── BeIdenticalTo.swift │ │ ├── BeLessThan.swift │ │ ├── BeLessThanOrEqual.swift │ │ ├── BeLogical.swift │ │ ├── BeNil.swift │ │ ├── BeginWith.swift │ │ ├── Contain.swift │ │ ├── EndWith.swift │ │ ├── Equal.swift │ │ ├── Match.swift │ │ ├── MatcherProtocols.swift │ │ └── RaisesException.swift │ ├── Nimble.h │ ├── Utils │ │ ├── Functional.swift │ │ ├── Poll.swift │ │ ├── SourceLocation.swift │ │ └── Stringers.swift │ ├── Wrappers │ │ ├── AsyncMatcherWrapper.swift │ │ ├── BasicMatcherWrapper.swift │ │ ├── FullMatcherWrapper.swift │ │ ├── MatcherFunc.swift │ │ ├── NonNilMatcherWrapper.swift │ │ └── ObjCMatcher.swift │ └── objc │ │ ├── DSL.h │ │ ├── DSL.m │ │ ├── NMBExceptionCapture.h │ │ └── NMBExceptionCapture.m ├── NimbleTests │ ├── AsynchronousTest.swift │ ├── Helpers │ │ ├── ObjectWithLazyProperty.swift │ │ └── utils.swift │ ├── Info.plist │ ├── Matchers │ │ ├── BeAKindOfTest.swift │ │ ├── BeAnInstanceOfTest.swift │ │ ├── BeCloseToTest.swift │ │ ├── BeEmptyTest.swift │ │ ├── BeGreaterThanOrEqualToTest.swift │ │ ├── BeGreaterThanTest.swift │ │ ├── BeIdenticalToObjectTest.swift │ │ ├── BeIdenticalToTest.swift │ │ ├── BeLessThanOrEqualToTest.swift │ │ ├── BeLessThanTest.swift │ │ ├── BeLogicalTest.swift │ │ ├── BeNilTest.swift │ │ ├── BeginWithTest.swift │ │ ├── ContainTest.swift │ │ ├── EndWithTest.swift │ │ ├── EqualTest.swift │ │ ├── MatchTest.swift │ │ └── RaisesExceptionTest.swift │ ├── SynchronousTests.swift │ └── objc │ │ ├── Nimble-OSXTests-Bridging-Header.h │ │ ├── NimbleSpecHelper.h │ │ ├── NimbleTests-Bridging-Header.h │ │ ├── ObjCAsyncTest.m │ │ ├── ObjCBeAnInstanceOfTest.m │ │ ├── ObjCBeCloseToTest.m │ │ ├── ObjCBeFalseTest.m │ │ ├── ObjCBeFalsyTest.m │ │ ├── ObjCBeGreaterThanOrEqualToTest.m │ │ ├── ObjCBeGreaterThanTest.m │ │ ├── ObjCBeIdenticalToTest.m │ │ ├── ObjCBeKindOfTest.m │ │ ├── ObjCBeLessThanOrEqualToTest.m │ │ ├── ObjCBeLessThanTest.m │ │ ├── ObjCBeNilTest.m │ │ ├── ObjCBeTrueTest.m │ │ ├── ObjCBeTruthyTest.m │ │ ├── ObjCBeginWithTest.m │ │ ├── ObjCContainTest.m │ │ ├── ObjCEndWithTest.m │ │ ├── ObjCEqualTest.m │ │ ├── ObjCMatchTest.m │ │ └── ObjCRaiseExceptionTest.m ├── README.md └── test └── Quick ├── .gitignore ├── .gitmodules ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── Quick Templates └── Quick Spec Class.xctemplate │ ├── Objective-C │ └── ___FILEBASENAME___.m │ ├── Swift │ └── ___FILEBASENAME___.swift │ ├── TemplateIcon.icns │ └── TemplateInfo.plist ├── Quick.podspec ├── Quick.xcodeproj ├── project.pbxproj ├── project.pbxproj.orig ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ ├── Quick-OSX.xcscheme │ └── Quick-iOS.xcscheme ├── Quick.xcworkspace └── contents.xcworkspacedata ├── Quick ├── Callsite.swift ├── Configuration │ ├── Configuration.swift │ ├── QuickConfiguration.h │ └── QuickConfiguration.m ├── DSL │ ├── DSL.swift │ ├── QCKDSL.h │ ├── QCKDSL.m │ └── World+DSL.swift ├── Example.swift ├── ExampleGroup.swift ├── ExampleMetadata.swift ├── Failure.swift ├── Filter.swift ├── Hooks │ ├── Closures.swift │ ├── ExampleHooks.swift │ └── SuiteHooks.swift ├── Info.plist ├── NSString+QCKSelectorName.h ├── NSString+QCKSelectorName.m ├── Quick.h ├── QuickSpec.h ├── QuickSpec.m └── World.swift ├── QuickFocusedTests ├── FocusedTests+ObjC.m ├── FocusedTests.swift └── Info.plist ├── QuickTests ├── ExampleMetadataFunctionalTests.swift ├── Fixtures │ ├── FunctionalTests_SharedExamplesTests_SharedExamples.swift │ ├── Person.swift │ └── Poet.swift ├── FunctionalTests+ObjC.m ├── FunctionalTests.swift ├── FunctionalTests │ ├── AfterEachTests+ObjC.m │ ├── AfterEachTests.swift │ ├── AfterSuiteTests.swift │ ├── BeforeEachTests+ObjC.m │ ├── BeforeEachTests.swift │ ├── BeforeSuiteTests+Objc.m │ ├── BeforeSuiteTests.swift │ ├── Configuration │ │ ├── AfterEach │ │ │ ├── Configuration+AfterEach.swift │ │ │ └── Configuration+AfterEachTests.swift │ │ └── BeforeEach │ │ │ ├── Configuration+BeforeEach.swift │ │ │ └── Configuration+BeforeEachTests.swift │ ├── FailureTests+ObjC.m │ ├── ItTests+ObjC.m │ ├── ItTests.swift │ ├── PendingTests+ObjC.m │ ├── PendingTests.swift │ ├── SharedExamples+BeforeEachTests.swift │ ├── SharedExamplesTests.swift │ └── WorldExampleMetadataFunctionalTests.swift ├── Helpers │ ├── QCKSpecRunner.h │ ├── QCKSpecRunner.m │ ├── QuickTestsBridgingHeader.h │ └── XCTestObservationCenter.h ├── Info.plist └── QuickConfigurationTests.m ├── README.md └── Rakefile /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatashaTheRobot/DependencyInjectionSwiftExample/0f04224f7a13c33741a755708aeb8b6b12e292db/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | -------------------------------------------------------------------------------- /DependencyInjectionExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DependencyInjectionExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // DependencyInjectionExample 4 | // 5 | // Created by Natasha Murashev on 1/1/15. 6 | // Copyright (c) 2015 NatashaTheRobot. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /DependencyInjectionExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /DependencyInjectionExample/Images.xcassets/Bob.imageset/Bob@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatashaTheRobot/DependencyInjectionSwiftExample/0f04224f7a13c33741a755708aeb8b6b12e292db/DependencyInjectionExample/Images.xcassets/Bob.imageset/Bob@2x.png -------------------------------------------------------------------------------- /DependencyInjectionExample/Images.xcassets/Bob.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "scale" : "3x", 14 | "filename" : "Bob@2x.png" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /DependencyInjectionExample/Images.xcassets/Dave.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "scale" : "3x", 14 | "filename" : "Dave@2x.png" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /DependencyInjectionExample/Images.xcassets/Dave.imageset/Dave@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatashaTheRobot/DependencyInjectionSwiftExample/0f04224f7a13c33741a755708aeb8b6b12e292db/DependencyInjectionExample/Images.xcassets/Dave.imageset/Dave@2x.png -------------------------------------------------------------------------------- /DependencyInjectionExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.natashatherobot.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /DependencyInjectionExample/Minion.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Minion.swift 3 | // DependencyInjectionExample 4 | // 5 | // Created by Natasha Murashev on 1/1/15. 6 | // Copyright (c) 2015 NatashaTheRobot. All rights reserved. 7 | // 8 | 9 | struct Minion { 10 | let name: String 11 | } 12 | 13 | extension Minion: Equatable {} 14 | func == (lhs: Minion, rhs: Minion) -> Bool { 15 | return lhs.name == rhs.name 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /DependencyInjectionExample/MinionService.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MinionService.swift 3 | // DependencyInjectionExample 4 | // 5 | // Created by Natasha Murashev on 1/1/15. 6 | // Copyright (c) 2015 NatashaTheRobot. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class MinionService { 12 | 13 | enum MinionDataResult { 14 | case Success([Minion]) 15 | case Failure(NSError) 16 | } 17 | 18 | func getTheMinions(completionHandler: (MinionDataResult) -> Void) { 19 | println("pretend we're getting minions asynchronously") 20 | let minionData = [Minion(name: "Bob"), Minion(name: "Dave")] 21 | completionHandler(MinionDataResult.Success(minionData)) 22 | 23 | // Uncomment if you want to test our an error scenario 24 | // let error = NSError(domain: "Error", 25 | // code: 400, 26 | // userInfo: [NSLocalizedDescriptionKey : "Oops! The Minions are missing on a new fun adventure!"]) 27 | // completionHandler(MinionDataResult.Failure(error)) 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /DependencyInjectionExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // DependencyInjectionExample 4 | // 5 | // Created by Natasha Murashev on 1/1/15. 6 | // Copyright (c) 2015 NatashaTheRobot. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UITableViewController { 12 | 13 | var dataSource: [Minion]? 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | fetchMinions() 19 | } 20 | 21 | func fetchMinions(minionService: MinionService = MinionService()) { 22 | minionService.getTheMinions { [unowned self](minionDataResult) -> Void in 23 | switch (minionDataResult) { 24 | case .Success(let minionsData): 25 | self.dataSource = minionsData 26 | self.tableView.reloadData() 27 | case .Failure(let error): 28 | let alertController = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .Alert) 29 | let okAction = UIAlertAction(title: "Ok", style: .Cancel, handler: nil) 30 | alertController.addAction(okAction) 31 | self.presentViewController(alertController, animated: true, completion: nil) 32 | } 33 | 34 | } 35 | } 36 | 37 | // MARK: UITableViewDataSource 38 | 39 | override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 40 | return dataSource?.count ?? 0 41 | } 42 | 43 | override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 44 | 45 | let cell = tableView.dequeueReusableCellWithIdentifier("minionCell") as UITableViewCell 46 | 47 | if let minion = dataSource?[indexPath.row] { 48 | cell.textLabel?.text = minion.name 49 | cell.imageView?.image = UIImage(named: minion.name) 50 | } 51 | 52 | return cell 53 | } 54 | 55 | } 56 | 57 | 58 | -------------------------------------------------------------------------------- /DependencyInjectionExampleQuickTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.natashatherobot.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /DependencyInjectionExampleQuickTests/ViewControllerSpec.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewControllerSpec.swift 3 | // DependencyInjectionExample 4 | // 5 | // Created by Natasha Murashev on 1/4/15. 6 | // Copyright (c) 2015 NatashaTheRobot. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Quick 11 | import Nimble 12 | 13 | class ViewControllerSpec: QuickSpec { 14 | 15 | class Fake_MinionService: MinionService { 16 | var getTheMinionsWasCalled = false 17 | var fakeResult: MinionService.MinionDataResult? 18 | 19 | override func getTheMinions(completionHandler: (MinionDataResult) -> Void) { 20 | getTheMinionsWasCalled = true 21 | completionHandler(fakeResult!) 22 | } 23 | } 24 | 25 | 26 | override func spec() { 27 | var viewController: ViewController! 28 | 29 | 30 | beforeEach { 31 | let storyboard = UIStoryboard(name: "Main", 32 | bundle: NSBundle(forClass: self.dynamicType)) 33 | let navigationController = storyboard.instantiateInitialViewController() as UINavigationController 34 | viewController = navigationController.topViewController as ViewController 35 | 36 | UIApplication.sharedApplication().keyWindow!.rootViewController = navigationController 37 | NSRunLoop.mainRunLoop().runUntilDate(NSDate()) 38 | } 39 | 40 | describe(".fetchMinions") { 41 | context("Minions are fetched successfully") { 42 | it("sets the minions as the data source") { 43 | let fakeMinionService = Fake_MinionService() 44 | let minions = [Minion(name: "Bob"), Minion(name: "Dave")] 45 | fakeMinionService.fakeResult = MinionService.MinionDataResult.Success(minions) 46 | viewController.fetchMinions(minionService: fakeMinionService) 47 | 48 | expect(fakeMinionService.getTheMinionsWasCalled).to(beTrue()) 49 | 50 | // optionals are handled for you! (dataSource in this case!) 51 | expect(minions).to(equal(viewController.dataSource)) 52 | } 53 | } 54 | context("There is an error fetching minions") { 55 | it("shows an alert with error") { 56 | let fakeMinionService = Fake_MinionService() 57 | let error = NSError(domain: "Error", code: 400, userInfo: [NSLocalizedDescriptionKey : "Oops! The Minions are missing on a new fun adventure!"]) 58 | fakeMinionService.fakeResult = MinionService.MinionDataResult.Failure(error) 59 | viewController.fetchMinions(minionService: fakeMinionService) 60 | 61 | expect(fakeMinionService.getTheMinionsWasCalled).to(beTrue()) 62 | 63 | expect(viewController.presentedViewController).toEventually(beAnInstanceOf(UIAlertController)) 64 | } 65 | } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /DependencyInjectionExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.natashatherobot.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /DependencyInjectionExampleTests/ViewControllerTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewControllerTests.swift 3 | // DependencyInjectionExample 4 | // 5 | // Created by Natasha Murashev on 1/1/15. 6 | // Copyright (c) 2015 NatashaTheRobot. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Foundation 11 | import XCTest 12 | 13 | class ViewControllerTests: XCTestCase { 14 | 15 | var viewController: ViewController! 16 | 17 | class Fake_MinionService: MinionService { 18 | var getTheMinionsWasCalled = false 19 | var result = [Minion(name: "Bob"), Minion(name: "Dave")] 20 | 21 | override func getTheMinions(completionHandler: (MinionDataResult) -> Void) { 22 | getTheMinionsWasCalled = true 23 | completionHandler(MinionDataResult.Success(result)) 24 | } 25 | } 26 | 27 | override func setUp() { 28 | let storyboard = UIStoryboard(name: "Main", 29 | bundle: NSBundle(forClass: self.dynamicType)) 30 | let navigationController = storyboard.instantiateInitialViewController() as UINavigationController 31 | viewController = navigationController.topViewController as ViewController 32 | 33 | UIApplication.sharedApplication().keyWindow!.rootViewController = navigationController 34 | NSRunLoop.mainRunLoop().runUntilDate(NSDate()) 35 | } 36 | 37 | func test_fetchMinions() { 38 | let fakeMinionService = Fake_MinionService() 39 | 40 | viewController.fetchMinions(minionService: fakeMinionService) 41 | 42 | XCTAssertTrue(fakeMinionService.getTheMinionsWasCalled) 43 | 44 | if let dataSource = viewController.dataSource { 45 | XCTAssertEqual(fakeMinionService.result, dataSource) 46 | } else { 47 | XCTFail("Data Source should not be nil!!!") 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DependencyInjectionSwiftExample 2 | =============================== 3 | 4 | Playing with unit tests - dependency injection in Swift 5 | 6 | Original Blog Post - Dependency Injection with XCTest: http://natashatherobot.com/unit-testing-swift-dependency-injection/ 7 | 8 | Follow-up Blog Post - Dependency Injection with Quick: http://natashatherobot.com/unit-testing-in-swift-a-quick-look-at-quick/ 9 | -------------------------------------------------------------------------------- /Vendor/Nimble/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | xcuserdata/ 3 | build/ 4 | .idea 5 | DerivedData/ 6 | -------------------------------------------------------------------------------- /Vendor/Nimble/.travis.yml: -------------------------------------------------------------------------------- 1 | osx_image: xcode61 2 | language: objective-c 3 | 4 | env: 5 | matrix: 6 | - NIMBLE_RUNTIME_IOS_SDK_VERSION=8.1 TYPE=ios 7 | - NIMBLE_RUNTIME_OSX_SDK_VERSION=10.10 TYPE=osx 8 | 9 | script: ./test $TYPE 10 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "Nimble" 3 | s.version = "0.2.0" 4 | s.summary = "A Matcher Framework for Swift and Objective-C" 5 | s.description = <<-DESC 6 | Use Nimble to express the expected outcomes of Swift or Objective-C expressions. Inspired by Cedar. 7 | DESC 8 | s.homepage = "https://github.com/Quick/Nimble" 9 | s.license = { :type => "Apache 2.0", :file => "LICENSE.md" } 10 | s.author = "Quick Contributors" 11 | s.ios.deployment_target = "8.0" 12 | s.osx.deployment_target = "10.10" 13 | s.source = { :git => "https://github.com/Quick/Nimble.git", :tag => "v0.2.0" } 14 | 15 | s.source_files = "Nimble", "Nimble/**/*.{swift,h,m}" 16 | s.framework = "XCTest" 17 | end 18 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble.xcodeproj/xcshareddata/xcschemes/Nimble-OSX.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 72 | 74 | 75 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble.xcodeproj/xcshareddata/xcschemes/Nimble-iOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 72 | 74 | 75 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Adapters/AdapterProtocols.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Protocol for the assertion handler that Nimble uses for all expectations. 4 | public protocol AssertionHandler { 5 | func assert(assertion: Bool, message: String, location: SourceLocation) 6 | } 7 | 8 | /// Global backing interface for assertions that Nimble creates. 9 | /// Defaults to a private test handler that passes through to XCTest. 10 | /// 11 | /// @see AssertionHandler 12 | var CurrentAssertionHandler: AssertionHandler = XCTestHandler() 13 | 14 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Adapters/AssertionRecorder.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A data structure that stores information about an assertion when 4 | /// AssertionRecorder is set as the Nimble assertion handler. 5 | /// 6 | /// @see AssertionRecorder 7 | /// @see AssertionHandler 8 | public struct AssertionRecord { 9 | /// Whether the assertion succeeded or failed 10 | public let success: Bool 11 | /// The failure message the assertion would display on failure. 12 | public let message: String 13 | /// The source location the expectation occurred on. 14 | public let location: SourceLocation 15 | } 16 | 17 | /// An AssertionHandler that silently records assertions that Nimble makes. 18 | /// This is useful for testing failure messages for matchers. 19 | /// 20 | /// @see AssertionHandler 21 | public class AssertionRecorder : AssertionHandler { 22 | /// All the assertions that were captured by this recorder 23 | public var assertions = [AssertionRecord]() 24 | 25 | public init() {} 26 | 27 | public func assert(assertion: Bool, message: String, location: SourceLocation) { 28 | assertions.append( 29 | AssertionRecord( 30 | success: assertion, 31 | message: message, 32 | location: location)) 33 | } 34 | } 35 | 36 | /// Allows you to temporarily replace the current Nimble assertion handler with 37 | /// the one provided for the scope of the closure. 38 | /// 39 | /// Once the closure finishes, then the original Nimble assertion handler is restored. 40 | /// 41 | /// @see AssertionHandler 42 | public func withAssertionHandler(tempAssertionHandler: AssertionHandler, closure: () -> Void) { 43 | let oldRecorder = CurrentAssertionHandler 44 | let capturer = NMBExceptionCapture(handler: nil, finally: ({ 45 | CurrentAssertionHandler = oldRecorder 46 | })) 47 | CurrentAssertionHandler = tempAssertionHandler 48 | capturer.tryBlock { 49 | closure() 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Adapters/XCTestHandler.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import XCTest 3 | 4 | class XCTestHandler : AssertionHandler { 5 | func assert(assertion: Bool, message: String, location: SourceLocation) { 6 | if !assertion { 7 | XCTFail(message, file: location.file, line: location.line) 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/DSL+Wait.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Only classes, protocols, methods, properties, and subscript declarations can be 4 | /// bridges to Objective-C via the @objc keyword. This class encapsulates callback-style 5 | /// asynchronous waiting logic so that it may be called from Objective-C and Swift. 6 | @objc public class NMBWait { 7 | public class func until(#timeout: NSTimeInterval, action: (() -> Void) -> Void, file: String = __FILE__, line: UInt = __LINE__) -> Void { 8 | var completed = false 9 | var token: dispatch_once_t = 0 10 | let result = pollBlock(pollInterval: 0.01, timeoutInterval: timeout) { 11 | dispatch_once(&token) { 12 | dispatch_async(dispatch_get_main_queue()) { 13 | action() { completed = true } 14 | } 15 | } 16 | return completed 17 | } 18 | if result == PollResult.Failure { 19 | let pluralize = (timeout == 1 ? "" : "s") 20 | fail("Waited more than \(timeout) second\(pluralize)", file: file, line: line) 21 | } else if result == PollResult.Timeout { 22 | fail("Stall on main thread - too much enqueued on main run loop before waitUntil executes.", file: file, line: line) 23 | } 24 | } 25 | 26 | public class func until(action: (() -> Void) -> Void, file: String = __FILE__, line: UInt = __LINE__) -> Void { 27 | until(timeout: 1, action: action, file: file, line: line) 28 | } 29 | } 30 | 31 | /// Wait asynchronously until the done closure is called. 32 | /// 33 | /// This will advance the run loop. 34 | public func waitUntil(#timeout: NSTimeInterval, action: (() -> Void) -> Void, file: String = __FILE__, line: UInt = __LINE__) -> Void { 35 | NMBWait.until(timeout: timeout, action: action, file: file, line: line) 36 | } 37 | 38 | /// Wait asynchronously until the done closure is called. 39 | /// 40 | /// This will advance the run loop. 41 | public func waitUntil(action: (() -> Void) -> Void, file: String = __FILE__, line: UInt = __LINE__) -> Void { 42 | NMBWait.until(action, file: file, line: line) 43 | } -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/DSL.swift: -------------------------------------------------------------------------------- 1 | /// Make an expectation on a given actual value. The value given is lazily evaluated. 2 | public func expect(expression: @autoclosure () -> T?, file: String = __FILE__, line: UInt = __LINE__) -> Expectation { 3 | return Expectation( 4 | expression: Expression( 5 | expression: expression, 6 | location: SourceLocation(file: file, line: line))) 7 | } 8 | 9 | /// Make an expectation on a given actual value. The closure is lazily invoked. 10 | public func expect(file: String = __FILE__, line: UInt = __LINE__, expression: () -> T?) -> Expectation { 11 | return Expectation( 12 | expression: Expression( 13 | expression: expression, 14 | location: SourceLocation(file: file, line: line))) 15 | } 16 | 17 | /// Always fails the test with a message and a specified location. 18 | public func fail(message: String, #location: SourceLocation) { 19 | CurrentAssertionHandler.assert(false, message: message, location: location) 20 | } 21 | 22 | /// Always fails the test with a message. 23 | public func fail(message: String, file: String = __FILE__, line: UInt = __LINE__) { 24 | fail(message, location: SourceLocation(file: file, line: line)) 25 | } 26 | 27 | /// Always fails the test. 28 | public func fail(file: String = __FILE__, line: UInt = __LINE__) { 29 | fail("fail() always fails") 30 | } -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Expectation.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct Expectation { 4 | let expression: Expression 5 | 6 | public func verify(pass: Bool, _ message: String) { 7 | CurrentAssertionHandler.assert(pass, message: message, location: expression.location) 8 | } 9 | 10 | public func to(matcher: U) { 11 | var msg = FailureMessage() 12 | let pass = matcher.matches(expression, failureMessage: msg) 13 | if msg.actualValue == "" { 14 | msg.actualValue = "<\(stringify(expression.evaluate()))>" 15 | } 16 | verify(pass, msg.stringValue()) 17 | } 18 | 19 | public func toNot(matcher: U) { 20 | var msg = FailureMessage() 21 | let pass = matcher.doesNotMatch(expression, failureMessage: msg) 22 | if msg.actualValue == "" { 23 | msg.actualValue = "<\(stringify(expression.evaluate()))>" 24 | } 25 | verify(pass, msg.stringValue()) 26 | } 27 | 28 | public func notTo(matcher: U) { 29 | toNot(matcher) 30 | } 31 | 32 | // see: 33 | // - BasicMatcherWrapper for extension 34 | // - AsyncMatcherWrapper for extension 35 | // - NonNilMatcherWrapper for extension 36 | // 37 | // - NMBExpectation for Objective-C interface 38 | } 39 | 40 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Expression.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | // Memoizes the given closure, only calling the passed 4 | // closure once; even if repeat calls to the returned closure 5 | internal func memoizedClosure(closure: () -> T) -> (Bool) -> T { 6 | var cache: T? 7 | return ({ withoutCaching in 8 | if (withoutCaching || cache == nil) { 9 | cache = closure() 10 | } 11 | return cache! 12 | }) 13 | } 14 | 15 | public struct Expression { 16 | internal let _expression: (Bool) -> T? 17 | internal let _withoutCaching: Bool 18 | public let location: SourceLocation 19 | public var cache: T? 20 | 21 | public init(expression: () -> T?, location: SourceLocation) { 22 | self._expression = memoizedClosure(expression) 23 | self.location = location 24 | self._withoutCaching = false 25 | } 26 | 27 | public init(memoizedExpression: (Bool) -> T?, location: SourceLocation, withoutCaching: Bool) { 28 | self._expression = memoizedExpression 29 | self.location = location 30 | self._withoutCaching = withoutCaching 31 | } 32 | 33 | public func cast(block: (T?) -> U?) -> Expression { 34 | return Expression(expression: ({ block(self.evaluate()) }), location: self.location) 35 | } 36 | 37 | public func evaluate() -> T? { 38 | return self._expression(_withoutCaching) 39 | } 40 | 41 | public func withoutCaching() -> Expression { 42 | return Expression(memoizedExpression: self._expression, location: location, withoutCaching: true) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/FailureMessage.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | @objc 4 | public class FailureMessage { 5 | public var expected: String = "expected" 6 | public var actualValue: String? = "" // empty string -> use default; nil -> exclude 7 | public var to: String = "to" 8 | public var postfixMessage: String = "match" 9 | public var postfixActual: String = "" 10 | 11 | public init() { 12 | } 13 | 14 | public func stringValue() -> String { 15 | var value = "\(expected) \(to) \(postfixMessage)" 16 | if let actualValue = actualValue { 17 | value = "\(expected) \(to) \(postfixMessage), got \(actualValue)\(postfixActual)" 18 | } 19 | var lines: [String] = (value as NSString).componentsSeparatedByString("\n") as [String] 20 | let whitespace = NSCharacterSet.whitespaceAndNewlineCharacterSet() 21 | lines = lines.map { line in line.stringByTrimmingCharactersInSet(whitespace) } 22 | return "".join(lines) 23 | } 24 | } -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | net.jeffhui.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | NSHumanReadableCopyright 26 | Copyright © 2014 Jeff Hui. All rights reserved. 27 | 28 | 29 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Matchers/BeAKindOf.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is an instance of the given class. 4 | /// @see beAnInstanceOf if you want to match against the exact class 5 | public func beAKindOf(expectedClass: AnyClass) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | let instance = actualExpression.evaluate() 8 | if let validInstance = instance { 9 | failureMessage.actualValue = "<\(NSStringFromClass(validInstance.dynamicType)) instance>" 10 | } else { 11 | failureMessage.actualValue = "" 12 | } 13 | failureMessage.postfixMessage = "be a kind of \(NSStringFromClass(expectedClass))" 14 | return instance != nil && instance!.isKindOfClass(expectedClass) 15 | } 16 | } 17 | 18 | extension NMBObjCMatcher { 19 | public class func beAKindOfMatcher(expected: AnyClass) -> NMBMatcher { 20 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage, location in 21 | return beAKindOf(expected).matches(actualExpression, failureMessage: failureMessage) 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Matchers/BeAnInstanceOf.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is an instance of the given class. 4 | /// @see beAKindOf if you want to match against subclasses 5 | public func beAnInstanceOf(expectedClass: AnyClass) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | let instance = actualExpression.evaluate() 8 | if let validInstance = instance { 9 | failureMessage.actualValue = "<\(NSStringFromClass(validInstance.dynamicType)) instance>" 10 | } else { 11 | failureMessage.actualValue = "" 12 | } 13 | failureMessage.postfixMessage = "be an instance of \(NSStringFromClass(expectedClass))" 14 | return instance != nil && instance!.isMemberOfClass(expectedClass) 15 | } 16 | } 17 | 18 | extension NMBObjCMatcher { 19 | public class func beAnInstanceOfMatcher(expected: AnyClass) -> NMBMatcher { 20 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage, location in 21 | return beAnInstanceOf(expected).matches(actualExpression, failureMessage: failureMessage) 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Matchers/BeCloseTo.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | internal func isCloseTo(actualValue: Double?, expectedValue: Double, delta: Double, failureMessage: FailureMessage) -> Bool { 4 | failureMessage.postfixMessage = "be close to <\(stringify(expectedValue))> (within \(stringify(delta)))" 5 | if actualValue != nil { 6 | failureMessage.actualValue = "<\(stringify(actualValue!))>" 7 | } else { 8 | failureMessage.actualValue = "" 9 | } 10 | return actualValue != nil && abs(actualValue! - expectedValue) < delta 11 | } 12 | 13 | /// A Nimble matcher that succeeds when a value is close to another. This is used for floating 14 | /// point values which can have imprecise results when doing arithmetic on them. 15 | /// 16 | /// @see equal 17 | public func beCloseTo(expectedValue: Double, within delta: Double = 0.0001) -> NonNilMatcherFunc { 18 | return NonNilMatcherFunc { actualExpression, failureMessage in 19 | return isCloseTo(actualExpression.evaluate(), expectedValue, delta, failureMessage) 20 | } 21 | } 22 | 23 | /// A Nimble matcher that succeeds when a value is close to another. This is used for floating 24 | /// point values which can have imprecise results when doing arithmetic on them. 25 | /// 26 | /// @see equal 27 | public func beCloseTo(expectedValue: NMBDoubleConvertible, within delta: Double = 0.0001) -> NonNilMatcherFunc { 28 | return NonNilMatcherFunc { actualExpression, failureMessage in 29 | return isCloseTo(actualExpression.evaluate()?.doubleValue, expectedValue.doubleValue, delta, failureMessage) 30 | } 31 | } 32 | 33 | @objc public class NMBObjCBeCloseToMatcher : NMBMatcher { 34 | var _expected: NSNumber 35 | var _delta: CDouble 36 | init(expected: NSNumber, within: CDouble) { 37 | _expected = expected 38 | _delta = within 39 | } 40 | 41 | public func matches(actualExpression: () -> NSObject!, failureMessage: FailureMessage, location: SourceLocation) -> Bool { 42 | let actualBlock: () -> NMBDoubleConvertible? = ({ 43 | return actualExpression() as? NMBDoubleConvertible 44 | }) 45 | let expr = Expression(expression: actualBlock, location: location) 46 | let matcher = NonNilMatcherWrapper(NonNilBasicMatcherWrapper(beCloseTo(self._expected, within: self._delta))) 47 | return matcher.matches(expr, failureMessage: failureMessage) 48 | } 49 | 50 | public func doesNotMatch(actualExpression: () -> NSObject!, failureMessage: FailureMessage, location: SourceLocation) -> Bool { 51 | let actualBlock: () -> NMBDoubleConvertible? = ({ 52 | return actualExpression() as? NMBDoubleConvertible 53 | }) 54 | let expr = Expression(expression: actualBlock, location: location) 55 | let matcher = NonNilMatcherWrapper(NonNilBasicMatcherWrapper(beCloseTo(self._expected, within: self._delta))) 56 | return matcher.doesNotMatch(expr, failureMessage: failureMessage) 57 | } 58 | 59 | public var within: (CDouble) -> NMBObjCBeCloseToMatcher { 60 | return ({ delta in 61 | return NMBObjCBeCloseToMatcher(expected: self._expected, within: delta) 62 | }) 63 | } 64 | } 65 | 66 | extension NMBObjCMatcher { 67 | public class func beCloseToMatcher(expected: NSNumber, within: CDouble) -> NMBObjCBeCloseToMatcher { 68 | return NMBObjCBeCloseToMatcher(expected: expected, within: within) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Matchers/BeEmpty.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | /// A Nimble matcher that succeeds when a value is "empty". For collections, this 5 | /// means the are no items in that collection. For strings, it is an empty string. 6 | public func beEmpty() -> NonNilMatcherFunc { 7 | return NonNilMatcherFunc { actualExpression, failureMessage in 8 | failureMessage.postfixMessage = "be empty" 9 | let actualSeq = actualExpression.evaluate() 10 | if actualSeq == nil { 11 | return true 12 | } 13 | var generator = actualSeq!.generate() 14 | return generator.next() == nil 15 | } 16 | } 17 | 18 | /// A Nimble matcher that succeeds when a value is "empty". For collections, this 19 | /// means the are no items in that collection. For strings, it is an empty string. 20 | public func beEmpty() -> NonNilMatcherFunc { 21 | return NonNilMatcherFunc { actualExpression, failureMessage in 22 | failureMessage.postfixMessage = "be empty" 23 | let actualString = actualExpression.evaluate() 24 | return actualString == nil || actualString!.length == 0 25 | } 26 | } 27 | 28 | // Without specific overrides, beEmpty() is ambiguous for NSDictionary, NSArray, 29 | // etc, since they conform to SequenceType as well as NMBCollection. 30 | 31 | /// A Nimble matcher that succeeds when a value is "empty". For collections, this 32 | /// means the are no items in that collection. For strings, it is an empty string. 33 | public func beEmpty() -> NonNilMatcherFunc { 34 | return NonNilMatcherFunc { actualExpression, failureMessage in 35 | failureMessage.postfixMessage = "be empty" 36 | let actualDictionary = actualExpression.evaluate() 37 | return actualDictionary == nil || actualDictionary!.count == 0 38 | } 39 | } 40 | 41 | /// A Nimble matcher that succeeds when a value is "empty". For collections, this 42 | /// means the are no items in that collection. For strings, it is an empty string. 43 | public func beEmpty() -> NonNilMatcherFunc { 44 | return NonNilMatcherFunc { actualExpression, failureMessage in 45 | failureMessage.postfixMessage = "be empty" 46 | let actualArray = actualExpression.evaluate() 47 | return actualArray == nil || actualArray!.count == 0 48 | } 49 | } 50 | 51 | /// A Nimble matcher that succeeds when a value is "empty". For collections, this 52 | /// means the are no items in that collection. For strings, it is an empty string. 53 | public func beEmpty() -> NonNilMatcherFunc { 54 | return NonNilMatcherFunc { actualExpression, failureMessage in 55 | failureMessage.postfixMessage = "be empty" 56 | let actual = actualExpression.evaluate() 57 | return actual == nil || actual!.count == 0 58 | } 59 | } 60 | 61 | extension NMBObjCMatcher { 62 | class func beEmptyMatcher() -> NMBObjCMatcher { 63 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage, location in 64 | let expr = actualExpression.cast { $0 as? NMBCollection } 65 | return beEmpty().matches(expr, failureMessage: failureMessage) 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Matchers/BeGreaterThan.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | /// A Nimble matcher that succeeds when the actual value is greater than the expected value. 5 | public func beGreaterThan(expectedValue: T?) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | failureMessage.postfixMessage = "be greater than <\(stringify(expectedValue))>" 8 | return actualExpression.evaluate() > expectedValue 9 | } 10 | } 11 | 12 | /// A Nimble matcher that succeeds when the actual value is greater than the expected value. 13 | public func beGreaterThan(expectedValue: NMBComparable?) -> NonNilMatcherFunc { 14 | return NonNilMatcherFunc { actualExpression, failureMessage in 15 | failureMessage.postfixMessage = "be greater than <\(stringify(expectedValue))>" 16 | let actualValue = actualExpression.evaluate() 17 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) == NSComparisonResult.OrderedDescending 18 | return matches 19 | } 20 | } 21 | 22 | public func >(lhs: Expectation, rhs: T) { 23 | lhs.to(beGreaterThan(rhs)) 24 | } 25 | 26 | public func >(lhs: Expectation, rhs: NMBComparable?) { 27 | lhs.to(beGreaterThan(rhs)) 28 | } 29 | 30 | extension NMBObjCMatcher { 31 | public class func beGreaterThanMatcher(expected: NMBComparable?) -> NMBObjCMatcher { 32 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage, location in 33 | let expr = actualExpression.cast { $0 as NMBComparable? } 34 | return beGreaterThan(expected).matches(expr, failureMessage: failureMessage) 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Matchers/BeGreaterThanOrEqualTo.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is greater than 4 | /// or equal to the expected value. 5 | public func beGreaterThanOrEqualTo(expectedValue: T?) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | failureMessage.postfixMessage = "be greater than or equal to <\(stringify(expectedValue))>" 8 | let actualValue = actualExpression.evaluate() 9 | return actualValue >= expectedValue 10 | } 11 | } 12 | 13 | /// A Nimble matcher that succeeds when the actual value is greater than 14 | /// or equal to the expected value. 15 | public func beGreaterThanOrEqualTo(expectedValue: T?) -> NonNilMatcherFunc { 16 | return NonNilMatcherFunc { actualExpression, failureMessage in 17 | failureMessage.postfixMessage = "be greater than or equal to <\(stringify(expectedValue))>" 18 | let actualValue = actualExpression.evaluate() 19 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) != NSComparisonResult.OrderedAscending 20 | return matches 21 | } 22 | } 23 | 24 | public func >=(lhs: Expectation, rhs: T) { 25 | lhs.to(beGreaterThanOrEqualTo(rhs)) 26 | } 27 | 28 | public func >=(lhs: Expectation, rhs: T) { 29 | lhs.to(beGreaterThanOrEqualTo(rhs)) 30 | } 31 | 32 | extension NMBObjCMatcher { 33 | public class func beGreaterThanOrEqualToMatcher(expected: NMBComparable?) -> NMBObjCMatcher { 34 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage, location in 35 | let expr = actualExpression.cast { $0 as NMBComparable? } 36 | return beGreaterThanOrEqualTo(expected).matches(expr, failureMessage: failureMessage) 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Matchers/BeIdenticalTo.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | /// A Nimble matcher that succeeds when the actual value is the same instance 5 | /// as the expected instance. 6 | public func beIdenticalTo(expected: T?) -> NonNilMatcherFunc { 7 | return NonNilMatcherFunc { actualExpression, failureMessage in 8 | let actual = actualExpression.evaluate() 9 | failureMessage.actualValue = "\(identityAsString(actual))" 10 | failureMessage.postfixMessage = "be identical to \(identityAsString(expected))" 11 | return actual === expected && actual !== nil 12 | } 13 | } 14 | 15 | public func ===(lhs: Expectation, rhs: T?) { 16 | lhs.to(beIdenticalTo(rhs)) 17 | } 18 | public func !==(lhs: Expectation, rhs: T?) { 19 | lhs.toNot(beIdenticalTo(rhs)) 20 | } 21 | 22 | extension NMBObjCMatcher { 23 | public class func beIdenticalToMatcher(expected: NSObject?) -> NMBObjCMatcher { 24 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage, location in 25 | return beIdenticalTo(expected).matches(actualExpression, failureMessage: failureMessage) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Matchers/BeLessThan.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is less than the expected value. 4 | public func beLessThan(expectedValue: T?) -> NonNilMatcherFunc { 5 | return NonNilMatcherFunc { actualExpression, failureMessage in 6 | failureMessage.postfixMessage = "be less than <\(stringify(expectedValue))>" 7 | return actualExpression.evaluate() < expectedValue 8 | } 9 | } 10 | 11 | /// A Nimble matcher that succeeds when the actual value is less than the expected value. 12 | public func beLessThan(expectedValue: NMBComparable?) -> NonNilMatcherFunc { 13 | return NonNilMatcherFunc { actualExpression, failureMessage in 14 | failureMessage.postfixMessage = "be less than <\(stringify(expectedValue))>" 15 | let actualValue = actualExpression.evaluate() 16 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) == NSComparisonResult.OrderedAscending 17 | return matches 18 | } 19 | } 20 | 21 | public func <(lhs: Expectation, rhs: T) { 22 | lhs.to(beLessThan(rhs)) 23 | } 24 | 25 | public func <(lhs: Expectation, rhs: NMBComparable?) { 26 | lhs.to(beLessThan(rhs)) 27 | } 28 | 29 | extension NMBObjCMatcher { 30 | public class func beLessThanMatcher(expected: NMBComparable?) -> NMBObjCMatcher { 31 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage, location in 32 | let expr = actualExpression.cast { $0 as NMBComparable? } 33 | return beLessThan(expected).matches(expr, failureMessage: failureMessage) 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Matchers/BeLessThanOrEqual.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is less than 4 | /// or equal to the expected value. 5 | public func beLessThanOrEqualTo(expectedValue: T?) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | failureMessage.postfixMessage = "be less than or equal to <\(stringify(expectedValue))>" 8 | return actualExpression.evaluate() <= expectedValue 9 | } 10 | } 11 | 12 | /// A Nimble matcher that succeeds when the actual value is less than 13 | /// or equal to the expected value. 14 | public func beLessThanOrEqualTo(expectedValue: T?) -> NonNilMatcherFunc { 15 | return NonNilMatcherFunc { actualExpression, failureMessage in 16 | failureMessage.postfixMessage = "be less than or equal to <\(stringify(expectedValue))>" 17 | let actualValue = actualExpression.evaluate() 18 | return actualValue != nil && actualValue!.NMB_compare(expectedValue) != NSComparisonResult.OrderedDescending 19 | } 20 | } 21 | 22 | public func <=(lhs: Expectation, rhs: T) { 23 | lhs.to(beLessThanOrEqualTo(rhs)) 24 | } 25 | 26 | public func <=(lhs: Expectation, rhs: T) { 27 | lhs.to(beLessThanOrEqualTo(rhs)) 28 | } 29 | 30 | extension NMBObjCMatcher { 31 | public class func beLessThanOrEqualToMatcher(expected: NMBComparable?) -> NMBObjCMatcher { 32 | return NMBObjCMatcher(canMatchNil:false) { actualExpression, failureMessage, location in 33 | let expr = actualExpression.cast { $0 as? NMBComparable } 34 | return beLessThanOrEqualTo(expected).matches(expr, failureMessage: failureMessage) 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Matchers/BeLogical.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | internal func beBool(#expectedValue: BooleanType, #stringValue: String, #falseMatchesNil: Bool) -> MatcherFunc { 4 | return MatcherFunc { actualExpression, failureMessage in 5 | failureMessage.postfixMessage = "be \(stringValue)" 6 | let actual = actualExpression.evaluate() 7 | if expectedValue { 8 | return actual?.boolValue == expectedValue.boolValue 9 | } else if !falseMatchesNil { 10 | return actual != nil && actual!.boolValue != !expectedValue.boolValue 11 | } else { 12 | return actual?.boolValue != !expectedValue.boolValue 13 | } 14 | } 15 | } 16 | 17 | // MARK: beTrue() / beFalse() 18 | 19 | /// A Nimble matcher that succeeds when the actual value is exactly true. 20 | /// This matcher will not match against nils. 21 | public func beTrue() -> NonNilMatcherFunc { 22 | return basicMatcherWithFailureMessage(equal(true)) { failureMessage in 23 | failureMessage.postfixMessage = "be true" 24 | } 25 | } 26 | 27 | /// A Nimble matcher that succeeds when the actual value is exactly false. 28 | /// This matcher will not match against nils. 29 | public func beFalse() -> NonNilMatcherFunc { 30 | return basicMatcherWithFailureMessage(equal(false)) { failureMessage in 31 | failureMessage.postfixMessage = "be false" 32 | } 33 | } 34 | 35 | // MARK: beTruthy() / beFalsy() 36 | 37 | /// A Nimble matcher that succeeds when the actual value is not logically false. 38 | public func beTruthy() -> MatcherFunc { 39 | return beBool(expectedValue: true, stringValue: "truthy", falseMatchesNil: true) 40 | } 41 | 42 | /// A Nimble matcher that succeeds when the actual value is logically false. 43 | /// This matcher will match against nils. 44 | public func beFalsy() -> MatcherFunc { 45 | return beBool(expectedValue: false, stringValue: "falsy", falseMatchesNil: true) 46 | } 47 | 48 | extension NMBObjCMatcher { 49 | public class func beTruthyMatcher() -> NMBObjCMatcher { 50 | return NMBObjCMatcher { actualExpression, failureMessage, location in 51 | let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false as BooleanType? } 52 | return beTruthy().matches(expr, failureMessage: failureMessage) 53 | } 54 | } 55 | 56 | public class func beFalsyMatcher() -> NMBObjCMatcher { 57 | return NMBObjCMatcher { actualExpression, failureMessage, location in 58 | let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false as BooleanType? } 59 | return beFalsy().matches(expr, failureMessage: failureMessage) 60 | } 61 | } 62 | 63 | public class func beTrueMatcher() -> NMBObjCMatcher { 64 | return NMBObjCMatcher { actualExpression, failureMessage, location in 65 | let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false as Bool? } 66 | return beTrue().matches(expr, failureMessage: failureMessage) 67 | } 68 | } 69 | 70 | public class func beFalseMatcher() -> NMBObjCMatcher { 71 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage, location in 72 | let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false as Bool? } 73 | return beFalse().matches(expr, failureMessage: failureMessage) 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Matchers/BeNil.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is nil. 4 | public func beNil() -> MatcherFunc { 5 | return MatcherFunc { actualExpression, failureMessage in 6 | failureMessage.postfixMessage = "be nil" 7 | let actualValue = actualExpression.evaluate() 8 | return actualValue == nil 9 | } 10 | } 11 | 12 | extension NMBObjCMatcher { 13 | public class func beNilMatcher() -> NMBObjCMatcher { 14 | return NMBObjCMatcher { actualExpression, failureMessage, location in 15 | return beNil().matches(actualExpression, failureMessage: failureMessage) 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Matchers/BeginWith.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | /// A Nimble matcher that succeeds when the actual sequence's first element 5 | /// is equal to the expected value. 6 | public func beginWith(startingElement: T) -> NonNilMatcherFunc { 7 | return NonNilMatcherFunc { actualExpression, failureMessage in 8 | failureMessage.postfixMessage = "begin with <\(startingElement)>" 9 | if let actualValue = actualExpression.evaluate() { 10 | var actualGenerator = actualValue.generate() 11 | return actualGenerator.next() == startingElement 12 | } 13 | return false 14 | } 15 | } 16 | 17 | /// A Nimble matcher that succeeds when the actual collection's first element 18 | /// is equal to the expected object. 19 | public func beginWith(startingElement: AnyObject) -> NonNilMatcherFunc { 20 | return NonNilMatcherFunc { actualExpression, failureMessage in 21 | failureMessage.postfixMessage = "begin with <\(startingElement)>" 22 | let collection = actualExpression.evaluate() 23 | return collection != nil && collection!.indexOfObject(startingElement) == 0 24 | } 25 | } 26 | 27 | /// A Nimble matcher that succeeds when the actual string contains expected substring 28 | /// where the expected substring's location is zero. 29 | public func beginWith(startingSubstring: String) -> NonNilMatcherFunc { 30 | return NonNilMatcherFunc { actualExpression, failureMessage in 31 | failureMessage.postfixMessage = "begin with <\(startingSubstring)>" 32 | if let actual = actualExpression.evaluate() { 33 | let range = actual.rangeOfString(startingSubstring) 34 | return range != nil && range!.startIndex == actual.startIndex 35 | } 36 | return false 37 | } 38 | } 39 | 40 | extension NMBObjCMatcher { 41 | public class func beginWithMatcher(expected: AnyObject) -> NMBObjCMatcher { 42 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage, location in 43 | let actual = actualExpression.evaluate() 44 | if let actualString = actual as? String { 45 | let expr = actualExpression.cast { $0 as? String } 46 | return beginWith(expected as String).matches(expr, failureMessage: failureMessage) 47 | } else { 48 | let expr = actualExpression.cast { $0 as? NMBOrderedCollection } 49 | return beginWith(expected).matches(expr, failureMessage: failureMessage) 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Matchers/Contain.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual sequence contains the expected value. 4 | public func contain(items: T...) -> NonNilMatcherFunc { 5 | return NonNilMatcherFunc { actualExpression, failureMessage in 6 | failureMessage.postfixMessage = "contain <\(arrayAsString(items))>" 7 | if let actual = actualExpression.evaluate() { 8 | return all(items) { 9 | return contains(actual, $0) 10 | } 11 | } 12 | return false 13 | } 14 | } 15 | 16 | /// A Nimble matcher that succeeds when the actual string contains the expected substring. 17 | public func contain(substrings: String...) -> NonNilMatcherFunc { 18 | return NonNilMatcherFunc { actualExpression, failureMessage in 19 | failureMessage.postfixMessage = "contain <\(arrayAsString(substrings))>" 20 | if let actual = actualExpression.evaluate() { 21 | return all(substrings) { 22 | let scanRange = Range(start: actual.startIndex, end: actual.endIndex) 23 | let range = actual.rangeOfString($0, options: nil, range: scanRange, locale: nil) 24 | return range != nil && !range!.isEmpty 25 | } 26 | } 27 | return false 28 | } 29 | } 30 | 31 | /// A Nimble matcher that succeeds when the actual collection contains the expected object. 32 | public func contain(items: AnyObject?...) -> NonNilMatcherFunc { 33 | return NonNilMatcherFunc { actualExpression, failureMessage in 34 | failureMessage.postfixMessage = "contain <\(arrayAsString(items))>" 35 | let actual = actualExpression.evaluate() 36 | return all(items) { item in 37 | return actual != nil && actual!.containsObject(item) 38 | } 39 | } 40 | } 41 | 42 | extension NMBObjCMatcher { 43 | public class func containMatcher(expected: NSObject?) -> NMBObjCMatcher { 44 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage, location in 45 | let actualValue = actualExpression.evaluate() 46 | if let value = actualValue as? NMBContainer { 47 | let expr = Expression(expression: ({ value as NMBContainer }), location: location) 48 | return contain(expected).matches(expr, failureMessage: failureMessage) 49 | } else if let value = actualValue as? NSString { 50 | let expr = Expression(expression: ({ value as String }), location: location) 51 | return contain(expected as String).matches(expr, failureMessage: failureMessage) 52 | } else if actualValue != nil { 53 | failureMessage.postfixMessage = "contain <\(stringify(expected))> (only works for NSArrays, NSSets, NSHashTables, and NSStrings)" 54 | } else { 55 | failureMessage.postfixMessage = "contain <\(stringify(expected))>" 56 | } 57 | return false 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Matchers/EndWith.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | /// A Nimble matcher that succeeds when the actual sequence's last element 5 | /// is equal to the expected value. 6 | public func endWith(endingElement: T) -> NonNilMatcherFunc { 7 | return NonNilMatcherFunc { actualExpression, failureMessage in 8 | failureMessage.postfixMessage = "end with <\(endingElement)>" 9 | 10 | if let actualValue = actualExpression.evaluate() { 11 | var actualGenerator = actualValue.generate() 12 | var lastItem: T? 13 | var item: T? 14 | do { 15 | lastItem = item 16 | item = actualGenerator.next() 17 | } while(item != nil) 18 | 19 | return lastItem == endingElement 20 | } 21 | return false 22 | } 23 | } 24 | 25 | /// A Nimble matcher that succeeds when the actual collection's last element 26 | /// is equal to the expected object. 27 | public func endWith(endingElement: AnyObject) -> NonNilMatcherFunc { 28 | return NonNilMatcherFunc { actualExpression, failureMessage in 29 | failureMessage.postfixMessage = "end with <\(endingElement)>" 30 | let collection = actualExpression.evaluate() 31 | return collection != nil && collection!.indexOfObject(endingElement) == collection!.count - 1 32 | } 33 | } 34 | 35 | 36 | /// A Nimble matcher that succeeds when the actual string contains the expected substring 37 | /// where the expected substring's location is the actual string's length minus the 38 | /// expected substring's length. 39 | public func endWith(endingSubstring: String) -> NonNilMatcherFunc { 40 | return NonNilMatcherFunc { actualExpression, failureMessage in 41 | failureMessage.postfixMessage = "end with <\(endingSubstring)>" 42 | if let collection = actualExpression.evaluate() { 43 | let range = collection.rangeOfString(endingSubstring) 44 | return range != nil && range!.endIndex == collection.endIndex 45 | } 46 | return false 47 | } 48 | } 49 | 50 | extension NMBObjCMatcher { 51 | public class func endWithMatcher(expected: AnyObject) -> NMBObjCMatcher { 52 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage, location in 53 | let actual = actualExpression.evaluate() 54 | if let actualString = actual as? String { 55 | let expr = Expression(expression: ({ actualString }), location: location) 56 | return endWith(expected as String).matches(expr, failureMessage: failureMessage) 57 | } else { 58 | let expr = Expression(expression: ({ actual as? NMBOrderedCollection }), location: location) 59 | return endWith(expected).matches(expr, failureMessage: failureMessage) 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Matchers/Match.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual string satisfies the regular expression 4 | /// described by the expected string. 5 | public func match(expectedValue: String?) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | failureMessage.postfixMessage = "match <\(stringify(expectedValue))>" 8 | 9 | if let actual = actualExpression.evaluate() { 10 | if let regexp = expectedValue { 11 | return actual.rangeOfString(regexp, options: .RegularExpressionSearch) != nil 12 | } 13 | } 14 | 15 | return false 16 | } 17 | } 18 | 19 | extension NMBObjCMatcher { 20 | public class func matchMatcher(expected: NSString) -> NMBMatcher { 21 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage, location in 22 | let actual = actualExpression.cast { $0 as? String } 23 | return match(expected).matches(actual, failureMessage: failureMessage) 24 | } 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Nimble.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | FOUNDATION_EXPORT double NimbleVersionNumber; 6 | FOUNDATION_EXPORT const unsigned char NimbleVersionString[]; 7 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Utils/Functional.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | internal func all(array: [T], fn: (T) -> Bool) -> Bool { 4 | for item in array { 5 | if !fn(item) { 6 | return false 7 | } 8 | } 9 | return true 10 | } 11 | 12 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Utils/Poll.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | internal enum PollResult : BooleanType { 4 | case Success, Failure, Timeout 5 | 6 | var boolValue : Bool { 7 | return self == .Success 8 | } 9 | } 10 | 11 | internal class RunPromise { 12 | var token: dispatch_once_t = 0 13 | var didFinish = false 14 | var didFail = false 15 | 16 | init() {} 17 | 18 | func succeed() { 19 | dispatch_once(&self.token) { 20 | self.didFinish = false 21 | } 22 | } 23 | 24 | func fail(block: () -> Void) { 25 | dispatch_once(&self.token) { 26 | self.didFail = true 27 | block() 28 | } 29 | } 30 | } 31 | 32 | internal func stopRunLoop(runLoop: NSRunLoop, delay: NSTimeInterval) -> RunPromise { 33 | var promise = RunPromise() 34 | var killQueue = dispatch_queue_create("nimble.waitUntil.queue", DISPATCH_QUEUE_SERIAL) 35 | let killTimeOffset = Int64(CDouble(delay) * CDouble(NSEC_PER_SEC)) 36 | let killTime = dispatch_time(DISPATCH_TIME_NOW, killTimeOffset) 37 | dispatch_after(killTime, killQueue) { 38 | promise.fail { 39 | CFRunLoopStop(runLoop.getCFRunLoop()) 40 | } 41 | } 42 | return promise 43 | } 44 | 45 | internal func pollBlock(#pollInterval: NSTimeInterval, #timeoutInterval: NSTimeInterval, expression: () -> Bool) -> PollResult { 46 | let runLoop = NSRunLoop.mainRunLoop() 47 | 48 | var promise = stopRunLoop(runLoop, min(timeoutInterval, 0.2)) 49 | 50 | let startDate = NSDate() 51 | 52 | // trigger run loop to make sure enqueued tasks don't block our assertion polling 53 | // the stop run loop task above will abort us if necessary 54 | runLoop.runUntilDate(startDate) 55 | promise.succeed() 56 | 57 | if promise.didFail { 58 | return .Timeout 59 | } 60 | 61 | var pass: Bool = false 62 | do { 63 | pass = expression() 64 | if pass { 65 | break 66 | } 67 | 68 | let runDate = NSDate().dateByAddingTimeInterval(pollInterval) as NSDate 69 | runLoop.runUntilDate(runDate) 70 | } while(NSDate().timeIntervalSinceDate(startDate) < timeoutInterval); 71 | 72 | return pass ? .Success : .Failure 73 | } 74 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Utils/SourceLocation.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | @objc public class SourceLocation : Printable { 5 | public let file: String 6 | public let line: UInt 7 | 8 | init() { 9 | file = "Unknown File" 10 | line = 0 11 | } 12 | 13 | init(file: String, line: UInt) { 14 | self.file = file 15 | self.line = line 16 | } 17 | 18 | public var description: String { 19 | return "\(file):\(line)" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Utils/Stringers.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | internal func identityAsString(value: AnyObject?) -> String { 5 | if value == nil { 6 | return "nil" 7 | } 8 | return NSString(format: "<%p>", unsafeBitCast(value!, Int.self)) 9 | } 10 | 11 | internal func arrayAsString(items: [T], joiner: String = ", ") -> String { 12 | return items.reduce("") { accum, item in 13 | let prefix = (accum.isEmpty ? "" : joiner) 14 | return accum + prefix + "\(stringify(item))" 15 | } 16 | } 17 | 18 | @objc protocol NMBStringer { 19 | func NMB_stringify() -> String 20 | } 21 | 22 | internal func stringify(value: S) -> String { 23 | var generator = value.generate() 24 | var strings = [String]() 25 | var value: S.Generator.Element? 26 | do { 27 | value = generator.next() 28 | if value != nil { 29 | strings.append(stringify(value)) 30 | } 31 | } while value != nil 32 | let str = ", ".join(strings) 33 | return "[\(str)]" 34 | } 35 | 36 | extension NSArray : NMBStringer { 37 | func NMB_stringify() -> String { 38 | let str = self.componentsJoinedByString(", ") 39 | return "[\(str)]" 40 | } 41 | } 42 | 43 | internal func stringify(value: T) -> String { 44 | if value is Double { 45 | return NSString(format: "%.4f", (value as Double)) 46 | } 47 | return toString(value) 48 | } 49 | 50 | internal func stringify(value: T?) -> String { 51 | if let unboxed = value { 52 | return stringify(unboxed) 53 | } 54 | return "nil" 55 | } 56 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Wrappers/BasicMatcherWrapper.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | struct BasicMatcherWrapper: Matcher { 5 | let matcher: M 6 | 7 | func matches(actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 8 | return matcher.matches(actualExpression, failureMessage: failureMessage) 9 | } 10 | 11 | func doesNotMatch(actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 12 | return !matcher.matches(actualExpression, failureMessage: failureMessage) 13 | } 14 | } 15 | 16 | extension Expectation { 17 | public func to(matcher: U) { 18 | to(FullMatcherWrapper(matcher: BasicMatcherWrapper(matcher: matcher), to: "to", toNot: "to not")) 19 | } 20 | 21 | public func toNot(matcher: U) { 22 | toNot(FullMatcherWrapper(matcher: BasicMatcherWrapper(matcher: matcher), to: "to", toNot: "to not")) 23 | } 24 | 25 | public func notTo(matcher: U) { 26 | toNot(matcher) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Wrappers/FullMatcherWrapper.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | struct FullMatcherWrapper: Matcher { 5 | let matcher: M 6 | let to: String 7 | let toNot: String 8 | 9 | func matches(actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 10 | failureMessage.to = to 11 | return matcher.matches(actualExpression, failureMessage: failureMessage) 12 | } 13 | 14 | func doesNotMatch(actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 15 | failureMessage.to = toNot 16 | return matcher.doesNotMatch(actualExpression, failureMessage: failureMessage) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Wrappers/MatcherFunc.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct FullMatcherFunc: Matcher { 4 | public let matcher: (Expression, FailureMessage, Bool) -> Bool 5 | 6 | public init(_ matcher: (Expression, FailureMessage, Bool) -> Bool) { 7 | self.matcher = matcher 8 | } 9 | 10 | public func matches(actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 11 | return matcher(actualExpression, failureMessage, false) 12 | } 13 | 14 | public func doesNotMatch(actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 15 | return !matcher(actualExpression, failureMessage, true) 16 | } 17 | } 18 | 19 | public struct MatcherFunc: BasicMatcher { 20 | public let matcher: (Expression, FailureMessage) -> Bool 21 | 22 | public init(_ matcher: (Expression, FailureMessage) -> Bool) { 23 | self.matcher = matcher 24 | } 25 | 26 | public func matches(actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 27 | return matcher(actualExpression, failureMessage) 28 | } 29 | } 30 | 31 | public struct NonNilMatcherFunc: NonNilBasicMatcher { 32 | public let matcher: (Expression, FailureMessage) -> Bool 33 | 34 | public init(_ matcher: (Expression, FailureMessage) -> Bool) { 35 | self.matcher = matcher 36 | } 37 | 38 | public func matches(actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 39 | return matcher(actualExpression, failureMessage) 40 | } 41 | } 42 | 43 | public func fullMatcherFromBasicMatcher(matcher: M) -> FullMatcherFunc { 44 | return FullMatcherFunc { actualExpression, failureMessage, expectingToNotMatch in 45 | return matcher.matches(actualExpression, failureMessage: failureMessage) != expectingToNotMatch 46 | } 47 | } 48 | 49 | public func basicMatcherWithFailureMessage(matcher: M, postprocessor: (FailureMessage) -> Void) -> NonNilMatcherFunc { 50 | return NonNilMatcherFunc { actualExpression, failureMessage in 51 | let result = matcher.matches(actualExpression, failureMessage: failureMessage) 52 | postprocessor(failureMessage) 53 | return result 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/Wrappers/NonNilMatcherWrapper.swift: -------------------------------------------------------------------------------- 1 | struct NonNilMatcherWrapper: Matcher { 2 | let matcher: M 3 | let nilMessage = " (use beNil() to match nils)" 4 | 5 | init(_ matcher: M) { 6 | self.matcher = matcher 7 | } 8 | 9 | func matches(actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 10 | let pass = matcher.matches(actualExpression, failureMessage: failureMessage) 11 | if actualExpression.evaluate() == nil { 12 | failureMessage.postfixActual = nilMessage 13 | return false 14 | } 15 | return pass 16 | } 17 | 18 | func doesNotMatch(actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 19 | let pass = matcher.doesNotMatch(actualExpression, failureMessage: failureMessage) 20 | if actualExpression.evaluate() == nil { 21 | failureMessage.postfixActual = nilMessage 22 | return false 23 | } 24 | return pass 25 | } 26 | } 27 | 28 | struct NonNilBasicMatcherWrapper: Matcher { 29 | let matcher: M 30 | 31 | init(_ matcher: M) { 32 | self.matcher = matcher 33 | } 34 | 35 | func matches(actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 36 | return matcher.matches(actualExpression, failureMessage: failureMessage) 37 | } 38 | 39 | func doesNotMatch(actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 40 | return !matcher.matches(actualExpression, failureMessage: failureMessage) 41 | } 42 | } 43 | 44 | extension Expectation { 45 | public func to(matcher: U) { 46 | to(FullMatcherWrapper(matcher: NonNilMatcherWrapper(NonNilBasicMatcherWrapper(matcher)), to: "to", toNot: "to not")) 47 | } 48 | 49 | public func toNot(matcher: U) { 50 | toNot(FullMatcherWrapper(matcher: NonNilMatcherWrapper(NonNilBasicMatcherWrapper(matcher)), to: "to", toNot: "to not")) 51 | } 52 | 53 | public func notTo(matcher: U) { 54 | toNot(matcher) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/objc/NMBExceptionCapture.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NMBExceptionCapture : NSObject 4 | 5 | - (id)initWithHandler:(void(^)(NSException *))handler finally:(void(^)())finally; 6 | - (void)tryBlock:(void(^)())unsafeBlock; 7 | 8 | @end -------------------------------------------------------------------------------- /Vendor/Nimble/Nimble/objc/NMBExceptionCapture.m: -------------------------------------------------------------------------------- 1 | #import "NMBExceptionCapture.h" 2 | 3 | @interface NMBExceptionCapture () 4 | @property (nonatomic, copy) void(^handler)(NSException *exception); 5 | @property (nonatomic, copy) void(^finally)(); 6 | @end 7 | 8 | @implementation NMBExceptionCapture 9 | 10 | - (id)initWithHandler:(void(^)(NSException *))handler finally:(void(^)())finally { 11 | self = [super init]; 12 | if (self) { 13 | self.handler = handler; 14 | self.finally = finally; 15 | } 16 | return self; 17 | } 18 | 19 | - (void)tryBlock:(void(^)())unsafeBlock { 20 | @try { 21 | unsafeBlock(); 22 | } 23 | @catch (NSException *exception) { 24 | if (self.handler) { 25 | self.handler(exception); 26 | } 27 | } 28 | @finally { 29 | if (self.finally) { 30 | self.finally(); 31 | } 32 | } 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/AsynchronousTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class AsyncTest: XCTestCase { 5 | 6 | func testAsyncPolling() { 7 | var value = 0 8 | deferToMainQueue { value = 1 } 9 | expect(value).toEventually(equal(1)) 10 | 11 | deferToMainQueue { value = 0 } 12 | expect(value).toEventuallyNot(equal(1)) 13 | 14 | failsWithErrorMessage("expected to eventually not equal <0>, got <0>") { 15 | expect(value).toEventuallyNot(equal(0)) 16 | } 17 | failsWithErrorMessage("expected to eventually equal <1>, got <0>") { 18 | expect(value).toEventually(equal(1)) 19 | } 20 | } 21 | 22 | func testAsyncCallback() { 23 | waitUntil { done in 24 | done() 25 | } 26 | waitUntil { done in 27 | deferToMainQueue { 28 | done() 29 | } 30 | } 31 | failsWithErrorMessage("Waited more than 1.0 second") { 32 | waitUntil(timeout: 1) { done in return } 33 | } 34 | failsWithErrorMessage("Waited more than 0.01 seconds") { 35 | waitUntil(timeout: 0.01) { done in 36 | NSThread.sleepForTimeInterval(0.1) 37 | done() 38 | } 39 | } 40 | 41 | failsWithErrorMessage("expected to equal <2>, got <1>") { 42 | waitUntil { done in 43 | NSThread.sleepForTimeInterval(0.1) 44 | expect(1).to(equal(2)) 45 | done() 46 | } 47 | } 48 | } 49 | 50 | func testWaitUntilDetectsStalledMainThreadActivity() { 51 | dispatch_async(dispatch_get_main_queue()) { 52 | NSThread.sleepForTimeInterval(2.0) 53 | } 54 | 55 | failsWithErrorMessage("Stall on main thread - too much enqueued on main run loop before waitUntil executes.") { 56 | waitUntil { done in 57 | done() 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Helpers/ObjectWithLazyProperty.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class ObjectWithLazyProperty { 4 | init() {} 5 | lazy var value: String = "hello" 6 | lazy var anotherValue: String = { return "world" }() 7 | } 8 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Helpers/utils.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Nimble 3 | import XCTest 4 | 5 | func failsWithErrorMessage(message: String, closure: () -> Void, file: String = __FILE__, line: UInt = __LINE__, preferOriginalSourceLocation: Bool = false) { 6 | var filePath = file 7 | var lineNumber = line 8 | 9 | let recorder = AssertionRecorder() 10 | withAssertionHandler(recorder, closure) 11 | 12 | var lastFailure: AssertionRecord? 13 | if recorder.assertions.count > 0 { 14 | lastFailure = recorder.assertions[recorder.assertions.endIndex - 1] 15 | if lastFailure!.message == message { 16 | return 17 | } 18 | } 19 | 20 | if preferOriginalSourceLocation { 21 | if let failure = lastFailure { 22 | filePath = failure.location.file 23 | lineNumber = failure.location.line 24 | } 25 | } 26 | 27 | if lastFailure != nil { 28 | let msg = "Got failure message: \"\(lastFailure!.message)\", but expected \"\(message)\"" 29 | XCTFail(msg, file: filePath, line: lineNumber) 30 | } else { 31 | XCTFail("expected failure message, but got none", file: filePath, line: lineNumber) 32 | } 33 | } 34 | 35 | func failsWithErrorMessageForNil(message: String, closure: () -> Void, file: String = __FILE__, line: UInt = __LINE__, preferOriginalSourceLocation: Bool = false) { 36 | failsWithErrorMessage("\(message) (use beNil() to match nils)", closure, file: file, line: line, preferOriginalSourceLocation: preferOriginalSourceLocation) 37 | } 38 | 39 | func deferToMainQueue(action: () -> Void) { 40 | dispatch_async(dispatch_get_main_queue()) { 41 | NSThread.sleepForTimeInterval(0.01) 42 | action() 43 | } 44 | } 45 | 46 | public class NimbleHelper : NSObject { 47 | class func expectFailureMessage(message: NSString, block: () -> Void, file: String, line: UInt) { 48 | failsWithErrorMessage(message as String, block, file: file, line: line, preferOriginalSourceLocation: true) 49 | } 50 | 51 | class func expectFailureMessageForNil(message: NSString, block: () -> Void, file: String, line: UInt) { 52 | failsWithErrorMessageForNil(message as String, block, file: file, line: line, preferOriginalSourceLocation: true) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | net.jeffhui.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/BeAKindOfTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class TestNull : NSNull {} 5 | 6 | class BeAKindOfTest: XCTestCase { 7 | func testPositiveMatch() { 8 | expect(TestNull()).to(beAKindOf(NSNull)) 9 | expect(NSObject()).to(beAKindOf(NSObject)) 10 | expect(NSNumber(integer:1)).toNot(beAKindOf(NSDate)) 11 | } 12 | 13 | func testFailureMessages() { 14 | failsWithErrorMessageForNil("expected to not be a kind of NSNull, got ") { 15 | expect(nil as NSNull?).toNot(beAKindOf(NSNull)) 16 | } 17 | failsWithErrorMessageForNil("expected to be a kind of NSString, got ") { 18 | expect(nil as NSString?).to(beAKindOf(NSString)) 19 | } 20 | failsWithErrorMessage("expected to be a kind of NSString, got <__NSCFNumber instance>") { 21 | expect(NSNumber(integer:1)).to(beAKindOf(NSString)) 22 | } 23 | failsWithErrorMessage("expected to not be a kind of NSNumber, got <__NSCFNumber instance>") { 24 | expect(NSNumber(integer:1)).toNot(beAKindOf(NSNumber)) 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/BeAnInstanceOfTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class BeAnInstanceOfTest: XCTestCase { 5 | func testPositiveMatch() { 6 | expect(NSNull()).to(beAnInstanceOf(NSNull)) 7 | expect(NSNumber(integer:1)).toNot(beAnInstanceOf(NSDate)) 8 | } 9 | 10 | func testFailureMessages() { 11 | failsWithErrorMessageForNil("expected to not be an instance of NSNull, got ") { 12 | expect(nil as NSNull?).toNot(beAnInstanceOf(NSNull)) 13 | } 14 | failsWithErrorMessageForNil("expected to be an instance of NSString, got ") { 15 | expect(nil as NSString?).to(beAnInstanceOf(NSString)) 16 | } 17 | failsWithErrorMessage("expected to be an instance of NSString, got <__NSCFNumber instance>") { 18 | expect(NSNumber(integer:1)).to(beAnInstanceOf(NSString)) 19 | } 20 | failsWithErrorMessage("expected to not be an instance of NSNumber, got <__NSCFNumber instance>") { 21 | expect(NSNumber(integer:1)).toNot(beAnInstanceOf(NSNumber)) 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/BeCloseToTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class BeCloseToTest: XCTestCase { 5 | func testBeCloseTo() { 6 | expect(1.2).to(beCloseTo(1.2001)) 7 | expect(1.2 as CDouble).to(beCloseTo(1.2001)) 8 | expect(1.2 as Float).to(beCloseTo(1.2001)) 9 | 10 | failsWithErrorMessage("expected to not be close to <1.2001> (within 0.0001), got <1.2000>") { 11 | expect(1.2).toNot(beCloseTo(1.2001)) 12 | } 13 | } 14 | 15 | func testBeCloseToWithin() { 16 | expect(1.2).to(beCloseTo(9.300, within: 10)) 17 | 18 | failsWithErrorMessage("expected to not be close to <1.2001> (within 1.0000), got <1.2000>") { 19 | expect(1.2).toNot(beCloseTo(1.2001, within: 1.0)) 20 | } 21 | } 22 | 23 | func testBeCloseToWithNSNumber() { 24 | expect(NSNumber(double:1.2)).to(beCloseTo(9.300, within: 10)) 25 | expect(NSNumber(double:1.2)).to(beCloseTo(NSNumber(double:9.300), within: 10)) 26 | expect(1.2).to(beCloseTo(NSNumber(double:9.300), within: 10)) 27 | 28 | failsWithErrorMessage("expected to not be close to <1.2001> (within 1.0000), got <1.2000>") { 29 | expect(NSNumber(double:1.2)).toNot(beCloseTo(1.2001, within: 1.0)) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/BeEmptyTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class BeEmptyTest: XCTestCase { 5 | func testBeEmptyPositive() { 6 | expect([]).to(beEmpty()) 7 | expect([1]).toNot(beEmpty()) 8 | 9 | expect([] as [CInt]).to(beEmpty()) 10 | expect([1] as [CInt]).toNot(beEmpty()) 11 | 12 | expect(NSDictionary()).to(beEmpty()) 13 | expect(NSDictionary(object: 1, forKey: 1)).toNot(beEmpty()) 14 | 15 | expect(Dictionary()).to(beEmpty()) 16 | expect(["hi": 1]).toNot(beEmpty()) 17 | 18 | expect(NSArray()).to(beEmpty()) 19 | expect(NSArray(array: [1])).toNot(beEmpty()) 20 | 21 | expect(NSSet()).to(beEmpty()) 22 | expect(NSSet(array: [1])).toNot(beEmpty()) 23 | 24 | expect(NSString()).to(beEmpty()) 25 | expect(NSString(string: "hello")).toNot(beEmpty()) 26 | 27 | expect("").to(beEmpty()) 28 | expect("foo").toNot(beEmpty()) 29 | } 30 | 31 | func testBeEmptyNegative() { 32 | failsWithErrorMessageForNil("expected to be empty, got ") { 33 | expect(nil as NSString?).to(beEmpty()) 34 | } 35 | failsWithErrorMessageForNil("expected to not be empty, got ") { 36 | expect(nil as [CInt]?).toNot(beEmpty()) 37 | } 38 | 39 | failsWithErrorMessage("expected to not be empty, got <()>") { 40 | expect([]).toNot(beEmpty()) 41 | } 42 | failsWithErrorMessage("expected to be empty, got <[1]>") { 43 | expect([1]).to(beEmpty()) 44 | } 45 | 46 | failsWithErrorMessage("expected to not be empty, got <>") { 47 | expect("").toNot(beEmpty()) 48 | } 49 | failsWithErrorMessage("expected to be empty, got ") { 50 | expect("foo").to(beEmpty()) 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/BeGreaterThanOrEqualToTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class BeGreaterThanOrEqualToTest: XCTestCase { 5 | 6 | func testGreaterThanOrEqualTo() { 7 | expect(10).to(beGreaterThanOrEqualTo(10)) 8 | expect(10).to(beGreaterThanOrEqualTo(2)) 9 | expect(1).toNot(beGreaterThanOrEqualTo(2)) 10 | expect(NSNumber(int:1)).toNot(beGreaterThanOrEqualTo(2)) 11 | expect(NSNumber(int:2)).to(beGreaterThanOrEqualTo(NSNumber(int:2))) 12 | expect(1).to(beGreaterThanOrEqualTo(NSNumber(int:0))) 13 | 14 | failsWithErrorMessage("expected to be greater than or equal to <2>, got <0>") { 15 | expect(0).to(beGreaterThanOrEqualTo(2)) 16 | return 17 | } 18 | failsWithErrorMessage("expected to not be greater than or equal to <1>, got <1>") { 19 | expect(1).toNot(beGreaterThanOrEqualTo(1)) 20 | return 21 | } 22 | failsWithErrorMessageForNil("expected to be greater than or equal to <-2>, got ") { 23 | expect(nil as Int?).to(beGreaterThanOrEqualTo(-2)) 24 | } 25 | failsWithErrorMessageForNil("expected to not be greater than or equal to <1>, got ") { 26 | expect(nil as Int?).toNot(beGreaterThanOrEqualTo(1)) 27 | } 28 | } 29 | 30 | func testGreaterThanOrEqualToOperator() { 31 | expect(0) >= 0 32 | expect(1) >= 0 33 | expect(NSNumber(int:1)) >= 1 34 | expect(NSNumber(int:1)) >= NSNumber(int:1) 35 | 36 | failsWithErrorMessage("expected to be greater than or equal to <2>, got <1>") { 37 | expect(1) >= 2 38 | return 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/BeGreaterThanTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class BeGreaterThanTest: XCTestCase { 5 | func testGreaterThan() { 6 | expect(10).to(beGreaterThan(2)) 7 | expect(1).toNot(beGreaterThan(2)) 8 | expect(NSNumber(int:3)).to(beGreaterThan(2)) 9 | expect(NSNumber(int:1)).toNot(beGreaterThan(NSNumber(int:2))) 10 | 11 | failsWithErrorMessage("expected to be greater than <2>, got <0>") { 12 | expect(0).to(beGreaterThan(2)) 13 | } 14 | failsWithErrorMessage("expected to not be greater than <0>, got <1>") { 15 | expect(1).toNot(beGreaterThan(0)) 16 | } 17 | failsWithErrorMessageForNil("expected to be greater than <-2>, got ") { 18 | expect(nil as Int?).to(beGreaterThan(-2)) 19 | } 20 | failsWithErrorMessageForNil("expected to not be greater than <0>, got ") { 21 | expect(nil as Int?).toNot(beGreaterThan(0)) 22 | } 23 | } 24 | 25 | func testGreaterThanOperator() { 26 | expect(1) > 0 27 | expect(NSNumber(int:1)) > NSNumber(int:0) 28 | expect(NSNumber(int:1)) > 0 29 | 30 | failsWithErrorMessage("expected to be greater than <2.0000>, got <1.0000>") { 31 | expect(1) > 2 32 | return 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/BeIdenticalToObjectTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class BeIdenticalToObjectTest:XCTestCase { 5 | private class BeIdenticalToObjectTester {} 6 | private let testObjectA = BeIdenticalToObjectTester() 7 | private let testObjectB = BeIdenticalToObjectTester() 8 | 9 | func testBeIdenticalToPositive() { 10 | expect(testObjectA).to(beIdenticalTo(testObjectA)) 11 | } 12 | 13 | func testBeIdenticalToNegative() { 14 | expect(testObjectA).toNot(beIdenticalTo(testObjectB)) 15 | } 16 | 17 | func testBeIdenticalToPositiveMessage() { 18 | let message = NSString(format: "expected to be identical to <%p>, got <%p>", 19 | unsafeBitCast(testObjectB, Int.self), unsafeBitCast(testObjectA, Int.self)) 20 | failsWithErrorMessage(message) { 21 | expect(self.testObjectA).to(beIdenticalTo(self.testObjectB)) 22 | } 23 | } 24 | 25 | func testBeIdenticalToNegativeMessage() { 26 | let message = NSString(format: "expected to not be identical to <%p>, got <%p>", 27 | unsafeBitCast(testObjectA, Int.self), unsafeBitCast(testObjectA, Int.self)) 28 | failsWithErrorMessage(message) { 29 | expect(self.testObjectA).toNot(beIdenticalTo(self.testObjectA)) 30 | } 31 | } 32 | 33 | func testFailsOnNils() { 34 | let message1 = NSString(format: "expected to be identical to <%p>, got nil", 35 | unsafeBitCast(testObjectA, Int.self)) 36 | failsWithErrorMessageForNil(message1) { 37 | expect(nil as BeIdenticalToObjectTester?).to(beIdenticalTo(self.testObjectA)) 38 | } 39 | 40 | let message2 = NSString(format: "expected to not be identical to <%p>, got nil", 41 | unsafeBitCast(testObjectA, Int.self)) 42 | failsWithErrorMessageForNil(message2) { 43 | expect(nil as BeIdenticalToObjectTester?).toNot(beIdenticalTo(self.testObjectA)) 44 | } 45 | } 46 | 47 | func testOperators() { 48 | expect(testObjectA) === testObjectA 49 | expect(testObjectA) !== testObjectB 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/BeIdenticalToTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class BeIdenticalToTest: XCTestCase { 5 | func testBeIdenticalToPositive() { 6 | expect(NSNumber(integer:1)).to(beIdenticalTo(NSNumber(integer:1))) 7 | } 8 | 9 | func testBeIdenticalToNegative() { 10 | expect(NSNumber(integer:1)).toNot(beIdenticalTo("yo")) 11 | expect([1]).toNot(beIdenticalTo([1])) 12 | } 13 | 14 | func testBeIdenticalToPositiveMessage() { 15 | let num1 = NSNumber(integer:1) 16 | let num2 = NSNumber(integer:2) 17 | let message = NSString(format: "expected to be identical to <%p>, got <%p>", num2, num1) 18 | failsWithErrorMessage(message) { 19 | expect(num1).to(beIdenticalTo(num2)) 20 | } 21 | } 22 | 23 | func testBeIdenticalToNegativeMessage() { 24 | let value1 = NSArray(array: []) 25 | let value2 = NSArray(array: []) 26 | let message = NSString(format: "expected to not be identical to <%p>, got <%p>", value2, value1) 27 | failsWithErrorMessage(message) { 28 | expect(value1).toNot(beIdenticalTo(value2)) 29 | } 30 | } 31 | 32 | func testOperators() { 33 | expect(NSNumber(integer:1)) === NSNumber(integer:1) 34 | expect(NSNumber(integer:1)) !== NSNumber(integer:2) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/BeLessThanOrEqualToTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class BeLessThanOrEqualToTest: XCTestCase { 5 | func testLessThanOrEqualTo() { 6 | expect(10).to(beLessThanOrEqualTo(10)) 7 | expect(2).to(beLessThanOrEqualTo(10)) 8 | expect(2).toNot(beLessThanOrEqualTo(1)) 9 | 10 | expect(NSNumber(int:2)).to(beLessThanOrEqualTo(10)) 11 | expect(NSNumber(int:2)).toNot(beLessThanOrEqualTo(1)) 12 | expect(2).to(beLessThanOrEqualTo(NSNumber(int:10))) 13 | expect(2).toNot(beLessThanOrEqualTo(NSNumber(int:1))) 14 | 15 | failsWithErrorMessage("expected to be less than or equal to <0>, got <2>") { 16 | expect(2).to(beLessThanOrEqualTo(0)) 17 | return 18 | } 19 | failsWithErrorMessage("expected to not be less than or equal to <0>, got <0>") { 20 | expect(0).toNot(beLessThanOrEqualTo(0)) 21 | return 22 | } 23 | failsWithErrorMessageForNil("expected to be less than or equal to <2>, got ") { 24 | expect(nil as Int?).to(beLessThanOrEqualTo(2)) 25 | return 26 | } 27 | failsWithErrorMessageForNil("expected to not be less than or equal to <-2>, got ") { 28 | expect(nil as Int?).toNot(beLessThanOrEqualTo(-2)) 29 | return 30 | } 31 | } 32 | 33 | func testLessThanOrEqualToOperator() { 34 | expect(0) <= 1 35 | expect(1) <= 1 36 | 37 | failsWithErrorMessage("expected to be less than or equal to <1>, got <2>") { 38 | expect(2) <= 1 39 | return 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/BeLessThanTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class BeLessThanTest: XCTestCase { 5 | 6 | func testLessThan() { 7 | expect(2).to(beLessThan(10)) 8 | expect(2).toNot(beLessThan(1)) 9 | expect(NSNumber(integer:2)).to(beLessThan(10)) 10 | expect(NSNumber(integer:2)).toNot(beLessThan(1)) 11 | 12 | expect(2).to(beLessThan(NSNumber(integer:10))) 13 | expect(2).toNot(beLessThan(NSNumber(integer:1))) 14 | 15 | failsWithErrorMessage("expected to be less than <0>, got <2>") { 16 | expect(2).to(beLessThan(0)) 17 | } 18 | failsWithErrorMessage("expected to not be less than <1>, got <0>") { 19 | expect(0).toNot(beLessThan(1)) 20 | } 21 | 22 | failsWithErrorMessageForNil("expected to be less than <2>, got ") { 23 | expect(nil as Int?).to(beLessThan(2)) 24 | } 25 | failsWithErrorMessageForNil("expected to not be less than <-1>, got ") { 26 | expect(nil as Int?).toNot(beLessThan(-1)) 27 | } 28 | } 29 | 30 | func testLessThanOperator() { 31 | expect(0) < 1 32 | expect(NSNumber(int:0)) < 1 33 | 34 | failsWithErrorMessage("expected to be less than <1.0000>, got <2.0000>") { 35 | expect(2) < 1 36 | return 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/BeNilTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class BeNilTest: XCTestCase { 5 | func producesNil() -> Array? { 6 | return nil 7 | } 8 | 9 | func testBeNil() { 10 | expect(nil as Int?).to(beNil()) 11 | expect(1 as Int?).toNot(beNil()) 12 | expect(producesNil()).to(beNil()) 13 | 14 | failsWithErrorMessage("expected to not be nil, got ") { 15 | expect(nil as Int?).toNot(beNil()) 16 | } 17 | 18 | failsWithErrorMessage("expected to be nil, got <1>") { 19 | expect(1 as Int?).to(beNil()) 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/BeginWithTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class BeginWithTest: XCTestCase { 5 | 6 | func testPositiveMatches() { 7 | expect([1, 2, 3]).to(beginWith(1)) 8 | expect([1, 2, 3]).toNot(beginWith(2)) 9 | 10 | expect("foobar").to(beginWith("foo")) 11 | expect("foobar").toNot(beginWith("oo")) 12 | 13 | expect(NSString(string: "foobar")).to(beginWith("foo")) 14 | expect(NSString(string: "foobar")).toNot(beginWith("oo")) 15 | 16 | expect(NSArray(array: ["a", "b"])).to(beginWith("a")) 17 | expect(NSArray(array: ["a", "b"])).toNot(beginWith("b")) 18 | } 19 | 20 | func testNegativeMatches() { 21 | failsWithErrorMessageForNil("expected to begin with , got ") { 22 | expect(nil as NSArray?).to(beginWith("b")) 23 | } 24 | failsWithErrorMessageForNil("expected to not begin with , got ") { 25 | expect(nil as NSArray?).toNot(beginWith("b")) 26 | } 27 | 28 | failsWithErrorMessage("expected to begin with <2>, got <[1, 2, 3]>") { 29 | expect([1, 2, 3]).to(beginWith(2)) 30 | } 31 | failsWithErrorMessage("expected to not begin with <1>, got <[1, 2, 3]>") { 32 | expect([1, 2, 3]).toNot(beginWith(1)) 33 | } 34 | failsWithErrorMessage("expected to begin with , got ") { 35 | expect("batman").to(beginWith("atm")) 36 | } 37 | failsWithErrorMessage("expected to not begin with , got ") { 38 | expect("batman").toNot(beginWith("bat")) 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/ContainTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class ContainTest: XCTestCase { 5 | func testContain() { 6 | expect([1, 2, 3]).to(contain(1)) 7 | expect([1, 2, 3] as [CInt]).to(contain(1 as CInt)) 8 | expect([1, 2, 3] as Array).to(contain(1 as CInt)) 9 | expect(["foo", "bar", "baz"]).to(contain("baz")) 10 | expect([1, 2, 3]).toNot(contain(4)) 11 | expect(["foo", "bar", "baz"]).toNot(contain("ba")) 12 | expect(NSArray(array: ["a"])).to(contain("a")) 13 | expect(NSArray(array: ["a"])).toNot(contain("b")) 14 | expect(NSArray(object: 1) as NSArray?).to(contain(1)) 15 | 16 | failsWithErrorMessage("expected to contain , got <[a, b, c]>") { 17 | expect(["a", "b", "c"]).to(contain("bar")) 18 | } 19 | failsWithErrorMessage("expected to not contain , got <[a, b, c]>") { 20 | expect(["a", "b", "c"]).toNot(contain("b")) 21 | } 22 | 23 | failsWithErrorMessageForNil("expected to contain , got ") { 24 | expect(nil as [String]?).to(contain("bar")) 25 | } 26 | failsWithErrorMessageForNil("expected to not contain , got ") { 27 | expect(nil as [String]?).toNot(contain("b")) 28 | } 29 | } 30 | 31 | func testContainSubstring() { 32 | expect("foo").to(contain("o")) 33 | expect("foo").to(contain("oo")) 34 | expect("foo").toNot(contain("z")) 35 | expect("foo").toNot(contain("zz")) 36 | 37 | failsWithErrorMessage("expected to contain , got ") { 38 | expect("foo").to(contain("bar")) 39 | } 40 | failsWithErrorMessage("expected to not contain , got ") { 41 | expect("foo").toNot(contain("oo")) 42 | } 43 | } 44 | 45 | func testContainObjCSubstring() { 46 | let str = NSString(string: "foo") 47 | expect(str).to(contain(NSString(string: "o"))) 48 | expect(str).to(contain(NSString(string: "oo"))) 49 | expect(str).toNot(contain(NSString(string: "z"))) 50 | expect(str).toNot(contain(NSString(string: "zz"))) 51 | } 52 | 53 | func testVariadicArguments() { 54 | expect([1, 2, 3]).to(contain(1, 2)) 55 | expect([1, 2, 3]).toNot(contain(1, 4)) 56 | 57 | failsWithErrorMessage("expected to contain , got <[a, b, c]>") { 58 | expect(["a", "b", "c"]).to(contain("a", "bar")) 59 | } 60 | 61 | failsWithErrorMessage("expected to not contain , got <[a, b, c]>") { 62 | expect(["a", "b", "c"]).toNot(contain("bar", "b")) 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/EndWithTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class EndWithTest: XCTestCase { 5 | 6 | func testEndWithPositives() { 7 | expect([1, 2, 3]).to(endWith(3)) 8 | expect([1, 2, 3]).toNot(endWith(2)) 9 | 10 | expect("foobar").to(endWith("bar")) 11 | expect("foobar").toNot(endWith("oo")) 12 | 13 | expect(NSString(string: "foobar")).to(endWith("bar")) 14 | expect(NSString(string: "foobar")).toNot(endWith("oo")) 15 | 16 | expect(NSArray(array: ["a", "b"])).to(endWith("b")) 17 | expect(NSArray(array: ["a", "b"])).toNot(endWith("a")) 18 | } 19 | 20 | func testEndWithNegatives() { 21 | failsWithErrorMessageForNil("expected to end with <2>, got ") { 22 | expect(nil as [Int]?).to(endWith(2)) 23 | } 24 | failsWithErrorMessageForNil("expected to not end with <2>, got ") { 25 | expect(nil as [Int]?).toNot(endWith(2)) 26 | } 27 | 28 | failsWithErrorMessage("expected to end with <2>, got <[1, 2, 3]>") { 29 | expect([1, 2, 3]).to(endWith(2)) 30 | } 31 | failsWithErrorMessage("expected to not end with <3>, got <[1, 2, 3]>") { 32 | expect([1, 2, 3]).toNot(endWith(3)) 33 | } 34 | failsWithErrorMessage("expected to end with , got ") { 35 | expect("batman").to(endWith("atm")) 36 | } 37 | failsWithErrorMessage("expected to not end with , got ") { 38 | expect("batman").toNot(endWith("man")) 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/MatchTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class MatchTest:XCTestCase { 5 | func testMatchPositive() { 6 | expect("11:14").to(match("\\d{2}:\\d{2}")) 7 | } 8 | 9 | func testMatchNegative() { 10 | expect("hello").toNot(match("\\d{2}:\\d{2}")) 11 | } 12 | 13 | func testMatchPositiveMessage() { 14 | let message = "expected to match <\\d{2}:\\d{2}>, got " 15 | failsWithErrorMessage(message) { 16 | expect("hello").to(match("\\d{2}:\\d{2}")) 17 | } 18 | } 19 | 20 | func testMatchNegativeMessage() { 21 | let message = "expected to not match <\\d{2}:\\d{2}>, got <11:14>" 22 | failsWithErrorMessage(message) { 23 | expect("11:14").toNot(match("\\d{2}:\\d{2}")) 24 | } 25 | } 26 | 27 | func testMatchNils() { 28 | failsWithErrorMessageForNil("expected to match <\\d{2}:\\d{2}>, got ") { 29 | expect(nil as String?).to(match("\\d{2}:\\d{2}")) 30 | } 31 | 32 | failsWithErrorMessageForNil("expected to not match <\\d{2}:\\d{2}>, got ") { 33 | expect(nil as String?).toNot(match("\\d{2}:\\d{2}")) 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/Matchers/RaisesExceptionTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class RaisesExceptionTest: XCTestCase { 5 | var exception = NSException(name: "laugh", reason: "Lulz", userInfo: nil) 6 | 7 | func testCapturingInAutoClosure() { 8 | expect(exception.raise()).to(raiseException(named: "laugh")) 9 | expect(exception.raise()).to(raiseException()) 10 | 11 | failsWithErrorMessage("expected to raise exception named ") { 12 | expect(self.exception.raise()).to(raiseException(named: "foo")) 13 | } 14 | } 15 | 16 | func testCapturingInExplicitClosure() { 17 | expect { 18 | self.exception.raise() 19 | }.to(raiseException(named: "laugh")) 20 | 21 | expect { 22 | self.exception.raise() 23 | }.to(raiseException()) 24 | } 25 | 26 | func testCapturingWithReason() { 27 | expect(exception.raise()).to(raiseException(named: "laugh", reason: "Lulz")) 28 | 29 | failsWithErrorMessage("expected to raise any exception") { 30 | expect(self.exception).to(raiseException()) 31 | } 32 | failsWithErrorMessage("expected to not raise any exception") { 33 | expect(self.exception.raise()).toNot(raiseException()) 34 | } 35 | failsWithErrorMessage("expected to raise exception named and reason ") { 36 | expect(self.exception).to(raiseException(named: "laugh", reason: "Lulz")) 37 | } 38 | 39 | failsWithErrorMessage("expected to raise exception named and reason ") { 40 | expect(self.exception.raise()).to(raiseException(named: "bar", reason: "Lulz")) 41 | } 42 | failsWithErrorMessage("expected to not raise exception named ") { 43 | expect(self.exception.raise()).toNot(raiseException(named: "laugh")) 44 | } 45 | failsWithErrorMessage("expected to not raise exception named and reason ") { 46 | expect(self.exception.raise()).toNot(raiseException(named: "laugh", reason: "Lulz")) 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/SynchronousTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Nimble 3 | 4 | class SynchronousTest: XCTestCase { 5 | func testFailAlwaysFails() { 6 | failsWithErrorMessage("My error message") { 7 | fail("My error message") 8 | } 9 | failsWithErrorMessage("fail() always fails") { 10 | fail() 11 | } 12 | } 13 | 14 | func testToMatchesIfMatcherReturnsTrue() { 15 | expect(1).to(MatcherFunc { expr, failure in true }) 16 | expect{1}.to(MatcherFunc { expr, failure in true }) 17 | } 18 | 19 | func testToProvidesActualValueExpression() { 20 | var value: Int? 21 | expect(1).to(MatcherFunc { expr, failure in value = expr.evaluate(); return true }) 22 | expect(value).to(equal(1)) 23 | } 24 | 25 | func testToProvidesAMemoizedActualValueExpression() { 26 | var callCount = 0 27 | expect{ callCount++ }.to(MatcherFunc { expr, failure in 28 | expr.evaluate() 29 | expr.evaluate() 30 | return true 31 | }) 32 | expect(callCount).to(equal(1)) 33 | } 34 | 35 | func testToProvidesAMemoizedActualValueExpressionIsEvaluatedAtMatcherControl() { 36 | var callCount = 0 37 | expect{ callCount++ }.to(MatcherFunc { expr, failure in 38 | expect(callCount).to(equal(0)) 39 | expr.evaluate() 40 | return true 41 | }) 42 | expect(callCount).to(equal(1)) 43 | } 44 | 45 | func testToMatchAgainstLazyProperties() { 46 | expect(ObjectWithLazyProperty().value).to(equal("hello")) 47 | expect(ObjectWithLazyProperty().value).toNot(equal("world")) 48 | expect(ObjectWithLazyProperty().anotherValue).to(equal("world")) 49 | expect(ObjectWithLazyProperty().anotherValue).toNot(equal("hello")) 50 | } 51 | 52 | // repeated tests from to() for toNot() 53 | func testToNotMatchesIfMatcherReturnsTrue() { 54 | expect(1).toNot(MatcherFunc { expr, failure in false }) 55 | expect{1}.toNot(MatcherFunc { expr, failure in false }) 56 | } 57 | 58 | func testToNotProvidesActualValueExpression() { 59 | var value: Int? 60 | expect(1).toNot(MatcherFunc { expr, failure in value = expr.evaluate(); return false }) 61 | expect(value).to(equal(1)) 62 | } 63 | 64 | func testToNotProvidesAMemoizedActualValueExpression() { 65 | var callCount = 0 66 | expect{ callCount++ }.toNot(MatcherFunc { expr, failure in 67 | expr.evaluate() 68 | expr.evaluate() 69 | return false 70 | }) 71 | expect(callCount).to(equal(1)) 72 | } 73 | 74 | func testToNotProvidesAMemoizedActualValueExpressionIsEvaluatedAtMatcherControl() { 75 | var callCount = 0 76 | expect{ callCount++ }.toNot(MatcherFunc { expr, failure in 77 | expect(callCount).to(equal(0)) 78 | expr.evaluate() 79 | return false 80 | }) 81 | expect(callCount).to(equal(1)) 82 | } 83 | 84 | func testToNotNegativeMatches() { 85 | failsWithErrorMessage("expected to not match, got <1>") { 86 | expect(1).toNot(MatcherFunc { expr, failure in true }) 87 | } 88 | } 89 | 90 | 91 | func testNotToMatchesLikeToNot() { 92 | expect(1).notTo(MatcherFunc { expr, failure in false }) 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/Nimble-OSXTests-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/NimbleSpecHelper.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleTests-Swift.h" 3 | 4 | // Use this when you want to verify the failure message for when an expectation fails 5 | #define expectFailureMessage(MSG, BLOCK) \ 6 | [NimbleHelper expectFailureMessage:(MSG) block:(BLOCK) file:@(__FILE__) line:__LINE__]; 7 | 8 | // Use this when you want to verify the failure message with the nil message postfixed 9 | // to it: " (use beNil() to match nils)" 10 | #define expectNilFailureMessage(MSG, BLOCK) \ 11 | [NimbleHelper expectFailureMessageForNil:(MSG) block:(BLOCK) file:@(__FILE__) line:__LINE__]; 12 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/NimbleTests-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCAsyncTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "NimbleSpecHelper.h" 4 | 5 | @interface ObjCAsyncTest : XCTestCase 6 | 7 | @end 8 | 9 | @implementation ObjCAsyncTest 10 | 11 | - (void)testAsync { 12 | __block id obj = @1; 13 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 14 | obj = nil; 15 | }); 16 | expect(obj).toEventually(beNil()); 17 | } 18 | 19 | 20 | - (void)testAsyncWithCustomTimeout { 21 | __block id obj = nil; 22 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 23 | obj = @1; 24 | }); 25 | expect(obj).withTimeout(5).toEventuallyNot(beNil()); 26 | } 27 | 28 | - (void)testAsyncCallback { 29 | waitUntil(^(void (^done)(void)){ 30 | done(); 31 | }); 32 | 33 | expectFailureMessage(@"Waited more than 1.0 second", ^{ 34 | waitUntil(^(void (^done)(void)){ /* ... */ }); 35 | }); 36 | 37 | expectFailureMessage(@"Waited more than 0.01 seconds", ^{ 38 | waitUntilTimeout(0.01, ^(void (^done)(void)){ 39 | [NSThread sleepForTimeInterval:0.1]; 40 | done(); 41 | }); 42 | }); 43 | 44 | expectFailureMessage(@"expected to equal , got ", ^{ 45 | waitUntil(^(void (^done)(void)){ 46 | [NSThread sleepForTimeInterval:0.1]; 47 | expect(@"hello").to(equal(@"goodbye")); 48 | done(); 49 | }); 50 | }); 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCBeAnInstanceOfTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCBeAnInstanceOfTest : XCTestCase 5 | @end 6 | 7 | @implementation ObjCBeAnInstanceOfTest 8 | 9 | - (void)testPositiveMatches { 10 | NSNull *obj = [NSNull null]; 11 | expect(obj).to(beAnInstanceOf([NSNull class])); 12 | expect(@1).toNot(beAnInstanceOf([NSNull class])); 13 | } 14 | 15 | - (void)testNegativeMatches { 16 | expectFailureMessage(@"expected to be an instance of NSNull, got <__NSCFNumber instance>", ^{ 17 | expect(@1).to(beAnInstanceOf([NSNull class])); 18 | }); 19 | expectFailureMessage(@"expected to not be an instance of NSNull, got ", ^{ 20 | expect([NSNull null]).toNot(beAnInstanceOf([NSNull class])); 21 | }); 22 | } 23 | 24 | - (void)testNilMatches { 25 | expectNilFailureMessage(@"expected to be an instance of NSNull, got ", ^{ 26 | expect(nil).to(beAnInstanceOf([NSNull class])); 27 | }); 28 | 29 | expectNilFailureMessage(@"expected to not be an instance of NSNull, got ", ^{ 30 | expect(nil).toNot(beAnInstanceOf([NSNull class])); 31 | }); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCBeCloseToTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCBeCloseToTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCBeCloseToTest 9 | 10 | - (void)testPositiveMatches { 11 | expect(@1.2).to(beCloseTo(@1.2001)); 12 | expect(@1.2).to(beCloseTo(@2).within(10)); 13 | expect(@2).toNot(beCloseTo(@1)); 14 | expect(@1.00001).toNot(beCloseTo(@1).within(0.00000001)); 15 | } 16 | 17 | - (void)testNegativeMatches { 18 | expectFailureMessage(@"expected to be close to <0.0000> (within 0.0010), got <1.0000>", ^{ 19 | expect(@1).to(beCloseTo(@0)); 20 | }); 21 | expectFailureMessage(@"expected to not be close to <0.0000> (within 0.0010), got <0.0001>", ^{ 22 | expect(@(0.0001)).toNot(beCloseTo(@0)); 23 | }); 24 | } 25 | 26 | - (void)testNilMatches { 27 | expectNilFailureMessage(@"expected to be close to <0.0000> (within 0.0010), got ", ^{ 28 | expect(nil).to(beCloseTo(@0)); 29 | }); 30 | expectNilFailureMessage(@"expected to not be close to <0.0000> (within 0.0010), got ", ^{ 31 | expect(nil).toNot(beCloseTo(@0)); 32 | }); 33 | } 34 | 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCBeFalseTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCBeFalseTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCBeFalseTest 9 | 10 | - (void)testPositiveMatches { 11 | expect(@NO).to(beFalse()); 12 | expect(@YES).toNot(beFalse()); 13 | } 14 | 15 | - (void)testNegativeMatches { 16 | expectNilFailureMessage(@"expected to be false, got ", ^{ 17 | expect(nil).to(beFalse()); 18 | }); 19 | expectNilFailureMessage(@"expected to not be false, got ", ^{ 20 | expect(nil).toNot(beFalse()); 21 | }); 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCBeFalsyTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCBeFalsyTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCBeFalsyTest 9 | 10 | - (void)testPositiveMatches { 11 | expect(@NO).to(beFalsy()); 12 | expect(@YES).toNot(beFalsy()); 13 | expect(nil).to(beFalsy()); 14 | } 15 | 16 | - (void)testNegativeMatches { 17 | expectFailureMessage(@"expected to not be falsy, got ", ^{ 18 | expect(nil).toNot(beFalsy()); 19 | }); 20 | expectFailureMessage(@"expected to be falsy, got <1.0000>", ^{ 21 | expect(@1).to(beFalsy()); 22 | }); 23 | expectFailureMessage(@"expected to be truthy, got <0.0000>", ^{ 24 | expect(@NO).to(beTruthy()); 25 | }); 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCBeGreaterThanOrEqualToTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCBeGreaterThanOrEqualToTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCBeGreaterThanOrEqualToTest 9 | 10 | - (void)testPositiveMatches { 11 | expect(@2).to(beGreaterThanOrEqualTo(@2)); 12 | expect(@2).toNot(beGreaterThanOrEqualTo(@3)); 13 | } 14 | 15 | - (void)testNegativeMatches { 16 | expectFailureMessage(@"expected to be greater than or equal to <0.0000>, got <-1.0000>", ^{ 17 | expect(@(-1)).to(beGreaterThanOrEqualTo(@0)); 18 | }); 19 | expectFailureMessage(@"expected to not be greater than or equal to <1.0000>, got <2.0000>", ^{ 20 | expect(@2).toNot(beGreaterThanOrEqualTo(@(1))); 21 | }); 22 | } 23 | 24 | - (void)testNilMatches { 25 | expectNilFailureMessage(@"expected to be greater than or equal to <-1.0000>, got ", ^{ 26 | expect(nil).to(beGreaterThanOrEqualTo(@(-1))); 27 | }); 28 | expectNilFailureMessage(@"expected to not be greater than or equal to <1.0000>, got ", ^{ 29 | expect(nil).toNot(beGreaterThanOrEqualTo(@(1))); 30 | }); 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCBeGreaterThanTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCBeGreaterThanTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCBeGreaterThanTest 9 | 10 | - (void)testPositiveMatches { 11 | expect(@2).to(beGreaterThan(@1)); 12 | expect(@2).toNot(beGreaterThan(@2)); 13 | } 14 | 15 | - (void)testNegativeMatches { 16 | expectFailureMessage(@"expected to be greater than <0.0000>, got <-1.0000>", ^{ 17 | expect(@(-1)).to(beGreaterThan(@(0))); 18 | }); 19 | expectFailureMessage(@"expected to not be greater than <1.0000>, got <0.0000>", ^{ 20 | expect(@0).toNot(beGreaterThan(@(1))); 21 | }); 22 | } 23 | 24 | - (void)testNilMatches { 25 | expectNilFailureMessage(@"expected to be greater than <-1.0000>, got ", ^{ 26 | expect(nil).to(beGreaterThan(@(-1))); 27 | }); 28 | expectNilFailureMessage(@"expected to not be greater than <1.0000>, got ", ^{ 29 | expect(nil).toNot(beGreaterThan(@(1))); 30 | }); 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCBeIdenticalToTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCBeIdenticalToTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCBeIdenticalToTest 9 | 10 | - (void)testPositiveMatches { 11 | NSNull *obj = [NSNull null]; 12 | expect(obj).to(beIdenticalTo([NSNull null])); 13 | expect(@2).toNot(beIdenticalTo(@3)); 14 | } 15 | 16 | - (void)testNegativeMatches { 17 | NSNull *obj = [NSNull null]; 18 | expectFailureMessage(([NSString stringWithFormat:@"expected to be identical to <%p>, got <%p>", obj, @2]), ^{ 19 | expect(@2).to(beIdenticalTo(obj)); 20 | }); 21 | expectFailureMessage(([NSString stringWithFormat:@"expected to not be identical to <%p>, got <%p>", obj, obj]), ^{ 22 | expect(obj).toNot(beIdenticalTo(obj)); 23 | }); 24 | } 25 | 26 | - (void)testNilMatches { 27 | NSNull *obj = [NSNull null]; 28 | expectNilFailureMessage(@"expected to be identical to nil, got nil", ^{ 29 | expect(nil).to(beIdenticalTo(nil)); 30 | }); 31 | expectNilFailureMessage(([NSString stringWithFormat:@"expected to not be identical to <%p>, got nil", obj]), ^{ 32 | expect(nil).toNot(beIdenticalTo(obj)); 33 | }); 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCBeKindOfTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCBeKindOfTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCBeKindOfTest 9 | 10 | - (void)testPositiveMatches { 11 | NSMutableArray *array = [NSMutableArray array]; 12 | expect(array).to(beAKindOf([NSArray class])); 13 | expect(@1).toNot(beAKindOf([NSNull class])); 14 | } 15 | 16 | - (void)testNegativeMatches { 17 | expectFailureMessage(@"expected to be a kind of NSNull, got <__NSCFNumber instance>", ^{ 18 | expect(@1).to(beAKindOf([NSNull class])); 19 | }); 20 | expectFailureMessage(@"expected to not be a kind of NSNull, got ", ^{ 21 | expect([NSNull null]).toNot(beAKindOf([NSNull class])); 22 | }); 23 | } 24 | 25 | - (void)testNilMatches { 26 | expectNilFailureMessage(@"expected to be a kind of NSNull, got ", ^{ 27 | expect(nil).to(beAKindOf([NSNull class])); 28 | }); 29 | expectNilFailureMessage(@"expected to not be a kind of NSNull, got ", ^{ 30 | expect(nil).toNot(beAKindOf([NSNull class])); 31 | }); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCBeLessThanOrEqualToTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCBeLessThanOrEqualToTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCBeLessThanOrEqualToTest 9 | 10 | - (void)testPositiveMatches { 11 | expect(@2).to(beLessThanOrEqualTo(@2)); 12 | expect(@2).toNot(beLessThanOrEqualTo(@1)); 13 | } 14 | 15 | - (void)testNegativeMatches { 16 | expectFailureMessage(@"expected to be less than or equal to <1.0000>, got <2.0000>", ^{ 17 | expect(@2).to(beLessThanOrEqualTo(@1)); 18 | }); 19 | expectFailureMessage(@"expected to not be less than or equal to <1.0000>, got <1.0000>", ^{ 20 | expect(@1).toNot(beLessThanOrEqualTo(@1)); 21 | }); 22 | } 23 | 24 | - (void)testNilMatches { 25 | expectNilFailureMessage(@"expected to be less than or equal to <1.0000>, got ", ^{ 26 | expect(nil).to(beLessThanOrEqualTo(@1)); 27 | }); 28 | expectNilFailureMessage(@"expected to not be less than or equal to <-1.0000>, got ", ^{ 29 | expect(nil).toNot(beLessThanOrEqualTo(@(-1))); 30 | }); 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCBeLessThanTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCBeLessThanTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCBeLessThanTest 9 | 10 | - (void)testPositiveMatches { 11 | expect(@2).to(beLessThan(@3)); 12 | expect(@2).toNot(beLessThan(@2)); 13 | } 14 | 15 | - (void)testNegativeMatches { 16 | expectFailureMessage(@"expected to be less than <0.0000>, got <-1.0000>", ^{ 17 | expect(@(-1)).to(beLessThan(@0)); 18 | }); 19 | expectFailureMessage(@"expected to not be less than <1.0000>, got <0.0000>", ^{ 20 | expect(@0).toNot(beLessThan(@1)); 21 | }); 22 | } 23 | 24 | - (void)testNilMatches { 25 | expectNilFailureMessage(@"expected to be less than <-1.0000>, got ", ^{ 26 | expect(nil).to(beLessThan(@(-1))); 27 | }); 28 | expectNilFailureMessage(@"expected to not be less than <1.0000>, got ", ^{ 29 | expect(nil).toNot(beLessThan(@1)); 30 | }); 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCBeNilTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCBeNilTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCBeNilTest 9 | 10 | - (void)testPositiveMatches { 11 | expect(nil).to(beNil()); 12 | expect(@NO).toNot(beNil()); 13 | } 14 | 15 | - (void)testNegativeMatches { 16 | expectFailureMessage(@"expected to be nil, got <1.0000>", ^{ 17 | expect(@1).to(beNil()); 18 | }); 19 | expectFailureMessage(@"expected to not be nil, got ", ^{ 20 | expect(nil).toNot(beNil()); 21 | }); 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCBeTrueTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCBeTrueTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCBeTrueTest 9 | 10 | - (void)testPositiveMatches { 11 | expect(@YES).to(beTrue()); 12 | expect(@NO).toNot(beTrue()); 13 | expect(nil).toNot(beTrue()); 14 | } 15 | 16 | - (void)testNegativeMatches { 17 | expectFailureMessage(@"expected to be true, got <0.0000>", ^{ 18 | expect(@NO).to(beTrue()); 19 | }); 20 | expectFailureMessage(@"expected to be true, got ", ^{ 21 | expect(nil).to(beTrue()); 22 | }); 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCBeTruthyTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCBeTruthyTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCBeTruthyTest 9 | 10 | - (void)testPositiveMatches { 11 | expect(@YES).to(beTruthy()); 12 | expect(@NO).toNot(beTruthy()); 13 | expect(nil).toNot(beTruthy()); 14 | } 15 | 16 | - (void)testNegativeMatches { 17 | expectFailureMessage(@"expected to be truthy, got ", ^{ 18 | expect(nil).to(beTruthy()); 19 | }); 20 | expectFailureMessage(@"expected to not be truthy, got <1.0000>", ^{ 21 | expect(@1).toNot(beTruthy()); 22 | }); 23 | expectFailureMessage(@"expected to be truthy, got <0.0000>", ^{ 24 | expect(@NO).to(beTruthy()); 25 | }); 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCBeginWithTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCBeginWithTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCBeginWithTest 9 | 10 | - (void)testPositiveMatches { 11 | expect(@"hello world!").to(beginWith(@"hello")); 12 | expect(@"hello world!").toNot(beginWith(@"world")); 13 | 14 | NSArray *array = @[@1, @2]; 15 | expect(array).to(beginWith(@1)); 16 | expect(array).toNot(beginWith(@2)); 17 | } 18 | 19 | - (void)testNegativeMatches { 20 | expectFailureMessage(@"expected to begin with , got ", ^{ 21 | expect(@"foo").to(beginWith(@"bar")); 22 | }); 23 | expectFailureMessage(@"expected to not begin with , got ", ^{ 24 | expect(@"foo").toNot(beginWith(@"foo")); 25 | }); 26 | } 27 | 28 | - (void)testNilMatches { 29 | expectNilFailureMessage(@"expected to begin with <1>, got ", ^{ 30 | expect(nil).to(beginWith(@1)); 31 | }); 32 | expectNilFailureMessage(@"expected to not begin with <1>, got ", ^{ 33 | expect(nil).toNot(beginWith(@1)); 34 | }); 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCContainTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCContainTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCContainTest 9 | 10 | - (void)testPositiveMatches { 11 | NSArray *array = @[@1, @2]; 12 | expect(array).to(contain(@1)); 13 | expect(array).toNot(contain(@"HI")); 14 | expect(@"String").to(contain(@"Str")); 15 | expect(@"Other").toNot(contain(@"Str")); 16 | } 17 | 18 | - (void)testNegativeMatches { 19 | expectFailureMessage(@"expected to contain , got <(1,2)>", ^{ 20 | expect((@[@1, @2])).to(contain(@3)); 21 | }); 22 | expectFailureMessage(@"expected to not contain , got <(1,2)>", ^{ 23 | expect((@[@1, @2])).toNot(contain(@2)); 24 | }); 25 | 26 | expectFailureMessage(@"expected to contain , got ", ^{ 27 | expect(@"la").to(contain(@"hi")); 28 | }); 29 | expectFailureMessage(@"expected to not contain , got ", ^{ 30 | expect(@"hihihi").toNot(contain(@"hi")); 31 | }); 32 | } 33 | 34 | - (void)testNilMatches { 35 | expectNilFailureMessage(@"expected to contain <3.0000>, got ", ^{ 36 | expect(nil).to(contain(@3)); 37 | }); 38 | expectNilFailureMessage(@"expected to not contain <3.0000>, got ", ^{ 39 | expect(nil).toNot(contain(@3)); 40 | }); 41 | 42 | expectNilFailureMessage(@"expected to contain , got ", ^{ 43 | expect(nil).to(contain(@"hi")); 44 | }); 45 | expectNilFailureMessage(@"expected to not contain , got ", ^{ 46 | expect(nil).toNot(contain(@"hi")); 47 | }); 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCEndWithTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCEndWithTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCEndWithTest 9 | 10 | - (void)testPositiveMatches { 11 | NSArray *array = @[@1, @2]; 12 | expect(@"hello world!").to(endWith(@"world!")); 13 | expect(@"hello world!").toNot(endWith(@"hello")); 14 | expect(array).to(endWith(@2)); 15 | expect(array).toNot(endWith(@1)); 16 | expect(@1).toNot(contain(@"foo")); 17 | } 18 | 19 | - (void)testNegativeMatches { 20 | expectFailureMessage(@"expected to end with , got ", ^{ 21 | expect(@"hello world!").to(endWith(@"?")); 22 | }); 23 | expectFailureMessage(@"expected to not end with , got ", ^{ 24 | expect(@"hello world!").toNot(endWith(@"!")); 25 | }); 26 | } 27 | 28 | - (void)testNilMatches { 29 | expectNilFailureMessage(@"expected to end with <1>, got ", ^{ 30 | expect(nil).to(endWith(@1)); 31 | }); 32 | expectNilFailureMessage(@"expected to not end with <1>, got ", ^{ 33 | expect(nil).toNot(endWith(@1)); 34 | }); 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCEqualTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCEqualTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCEqualTest 9 | 10 | - (void)testPositiveMatches { 11 | expect(@1).to(equal(@1)); 12 | expect(@1).toNot(equal(@2)); 13 | expect(@1).notTo(equal(@2)); 14 | expect(@"hello").to(equal(@"hello")); 15 | } 16 | 17 | - (void)testNegativeMatches { 18 | expectFailureMessage(@"expected to equal <2.0000>, got <1.0000>", ^{ 19 | expect(@1).to(equal(@2)); 20 | }); 21 | expectFailureMessage(@"expected to not equal <1.0000>, got <1.0000>", ^{ 22 | expect(@1).toNot(equal(@1)); 23 | }); 24 | } 25 | 26 | - (void)testNilMatches { 27 | expectNilFailureMessage(@"expected to equal , got ", ^{ 28 | expect(nil).to(equal(nil)); 29 | }); 30 | expectNilFailureMessage(@"expected to not equal , got ", ^{ 31 | expect(nil).toNot(equal(nil)); 32 | }); 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCMatchTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCMatchTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCMatchTest 9 | 10 | - (void)testPositiveMatches { 11 | expect(@"11:14").to(match(@"\\d{2}:\\d{2}")); 12 | expect(@"hello").toNot(match(@"\\d{2}:\\d{2}")); 13 | } 14 | 15 | - (void)testNegativeMatches { 16 | expectFailureMessage(@"expected to match <\\d{2}:\\d{2}>, got ", ^{ 17 | expect(@"hello").to(match(@"\\d{2}:\\d{2}")); 18 | }); 19 | expectFailureMessage(@"expected to not match <\\d{2}:\\d{2}>, got <11:22>", ^{ 20 | expect(@"11:22").toNot(match(@"\\d{2}:\\d{2}")); 21 | }); 22 | } 23 | 24 | - (void)testNilMatches { 25 | expectNilFailureMessage(@"expected to match <\\d{2}:\\d{2}>, got ", ^{ 26 | expect(nil).to(match(@"\\d{2}:\\d{2}")); 27 | }); 28 | expectNilFailureMessage(@"expected to not match <\\d{2}:\\d{2}>, got ", ^{ 29 | expect(nil).toNot(match(@"\\d{2}:\\d{2}")); 30 | }); 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Vendor/Nimble/NimbleTests/objc/ObjCRaiseExceptionTest.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NimbleSpecHelper.h" 3 | 4 | @interface ObjCRaiseExceptionTest : XCTestCase 5 | 6 | @end 7 | 8 | @implementation ObjCRaiseExceptionTest 9 | 10 | - (void)testPositiveMatches { 11 | __block NSException *exception = [NSException exceptionWithName:NSInvalidArgumentException 12 | reason:@"No food" 13 | userInfo:nil]; 14 | expectAction([exception raise]).to(raiseException()); 15 | expectAction(exception).toNot(raiseException()); 16 | } 17 | 18 | - (void)testNegativeMatches { 19 | __block NSException *exception = [NSException exceptionWithName:NSInvalidArgumentException 20 | reason:@"No food" 21 | userInfo:nil]; 22 | expectFailureMessage(@"expected to raise any exception", ^{ 23 | expectAction([exception reason]).to(raiseException()); 24 | }); 25 | expectFailureMessage(@"expected to not raise any exception", ^{ 26 | expectAction([exception raise]).toNot(raiseException()); 27 | }); 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Vendor/Nimble/test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BUILD_DIR=`pwd`/build 4 | LATEST_IOS_SDK_VERSION=`xcodebuild -showsdks | grep iphonesimulator | cut -d ' ' -f 4 | ruby -e 'puts STDIN.read.chomp.split("\n").last'` 5 | LATEST_OSX_SDK_VERSION=`xcodebuild -showsdks | grep 'macosx' | cut -d ' ' -f 3 | ruby -e 'puts STDIN.read.chomp.split("\n").last'` 6 | BUILD_IOS_SDK_VERSION=${NIMBLE_BUILD_IOS_SDK_VERSION:-$LATEST_IOS_SDK_VERSION} 7 | RUNTIME_IOS_SDK_VERSION=${NIMBLE_RUNTIME_IOS_SDK_VERSION:-$LATEST_IOS_SDK_VERSION} 8 | BUILD_OSX_SDK_VERSION=${NIMBLE_BUILD_OSX_SDK_VERSION:-$LATEST_OSX_SDK_VERSION} 9 | 10 | set -e 11 | 12 | GREEN="\x1B[01;92m" 13 | CLEAR="\x1B[0m" 14 | 15 | function color_if_overridden { 16 | local actual=$1 17 | local env_var=$2 18 | if [ -z "$env_var" ]; then 19 | printf "$actual" 20 | else 21 | printf "$GREEN$actual$CLEAR" 22 | fi 23 | } 24 | 25 | function print_env { 26 | echo "=== Environment ===" 27 | echo " iOS:" 28 | echo " Latest iOS SDK: $LATEST_IOS_SDK_VERSION" 29 | echo " Building with iOS SDK: `color_if_overridden $BUILD_IOS_SDK_VERSION $NIMBLE_BUILD_IOS_SDK_VERSION`" 30 | echo " Running with iOS SDK: `color_if_overridden $RUNTIME_IOS_SDK_VERSION $NIMBLE_RUNTIME_IOS_SDK_VERSION`" 31 | echo 32 | echo " Mac OS X:" 33 | echo " Latest OS X SDK: $LATEST_OSX_SDK_VERSION" 34 | echo " Building with OS X SDK: `color_if_overridden $BUILD_OSX_SDK_VERSION $NIMBLE_BUILD_OSX_SDK_VERSION`" 35 | echo 36 | echo "======= END =======" 37 | echo 38 | } 39 | 40 | function run { 41 | echo "$GREEN==>$CLEAR $@" 42 | "$@" 43 | } 44 | 45 | function test_ios { 46 | run osascript -e 'tell app "iOS Simulator" to quit' 47 | run xcodebuild -project Nimble.xcodeproj -scheme "Nimble-iOS" -configuration "Debug" -sdk "iphonesimulator$BUILD_IOS_SDK_VERSION" -destination "name=iPad Air,OS=$RUNTIME_IOS_SDK_VERSION" build test 48 | 49 | run osascript -e 'tell app "iOS Simulator" to quit' 50 | run xcodebuild -project Nimble.xcodeproj -scheme "Nimble-iOS" -configuration "Debug" -sdk "iphonesimulator$BUILD_IOS_SDK_VERSION" -destination "name=iPhone 5s,OS=$RUNTIME_IOS_SDK_VERSION" build test 51 | } 52 | 53 | function test_osx { 54 | run xcodebuild -project Nimble.xcodeproj -scheme "Nimble-OSX" -configuration "Debug" -sdk "macosx$BUILD_OSX_SDK_VERSION" build test 55 | } 56 | 57 | function test() { 58 | test_ios 59 | test_osx 60 | } 61 | 62 | function clean { 63 | run rm -rf ~/Library/Developer/Xcode/DerivedData\; true 64 | } 65 | 66 | function help { 67 | echo "Usage: $0 COMMANDS" 68 | echo 69 | echo "COMMANDS:" 70 | echo " clean - Cleans the derived data directory of Xcode. Assumes default location" 71 | echo " ios - Runs the tests as an iOS device" 72 | echo " osx - Runs the tests on Mac OS X 10.10 (Yosemite and newer only)" 73 | echo " help - Displays this help" 74 | echo 75 | exit 1 76 | } 77 | 78 | function main { 79 | print_env 80 | for arg in $@ 81 | do 82 | case "$arg" in 83 | clean) clean ;; 84 | ios) test_ios ;; 85 | osx) test_osx ;; 86 | test) test ;; 87 | all) test ;; 88 | help) help ;; 89 | esac 90 | done 91 | 92 | if [ $# -eq 0 ]; then 93 | clean 94 | test 95 | fi 96 | } 97 | 98 | main $@ 99 | 100 | -------------------------------------------------------------------------------- /Vendor/Quick/.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | 28 | # Mac OS X 29 | .DS_Store 30 | -------------------------------------------------------------------------------- /Vendor/Quick/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Externals/Nimble"] 2 | path = Externals/Nimble 3 | url = https://github.com/Quick/Nimble.git 4 | -------------------------------------------------------------------------------- /Vendor/Quick/.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | 3 | before_install: git submodule update --init --recursive 4 | script: "rake" 5 | 6 | -------------------------------------------------------------------------------- /Vendor/Quick/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | - [Welcome to Quick!](#welcome-to-quick!) 5 | - [Reporting Bugs](#reporting-bugs) 6 | - [Building the Project](#building-the-project) 7 | - [Pull Requests](#pull-requests) 8 | - [Style Conventions](#style-conventions) 9 | - [Core Members](#core-members) 10 | - [Code of Conduct](#code-of-conduct) 11 | 12 | 13 | 14 | # Welcome to Quick! 15 | 16 | We're building a testing framework for a new generation of Swift and 17 | Objective-C developers. 18 | 19 | Quick should be easy to use and easy to maintain. Let's keep things 20 | simple and well-tested. 21 | 22 | ## Reporting Bugs 23 | 24 | Nothing is off-limits. If you're having a problem, we want to hear about 25 | it. 26 | 27 | - See a crash? File an issue. 28 | - Code isn't compiling, but you don't know why? Sounds like you should 29 | submit a new issue, bud. 30 | - Went to the kitchen, only to forget why you went in the first place? 31 | Better submit an issue. 32 | 33 | ## Building the Project 34 | 35 | - Use `Quick.xcworkspace` to work on Quick. The workspace includes 36 | Nimble, which is used in Quick's tests. 37 | 38 | ## Pull Requests 39 | 40 | - Nothing is trivial. Submit pull requests for anything: typos, 41 | whitespace, you name it. 42 | - Not all pull requests will be merged, but all will be acknowledged. If 43 | no one has provided feedback on your request, ping one of the owners 44 | by name. 45 | - Make sure your pull request includes any necessary updates to the 46 | README or other documentation. 47 | - Be sure the unit tests for both the OS X and iOS targets of both Quick 48 | and Nimble pass before submitting your pull request. You can run all 49 | the iOS and OS X unit tests using `rake test`. 50 | 51 | ### Style Conventions 52 | 53 | - Indent using 4 spaces. 54 | - Keep lines 100 characters or shorter. Break long statements into 55 | shorter ones over multiple lines. 56 | - In Objective-C, use `#pragma mark -` to mark public, internal, 57 | protocol, and superclass methods. See `QuickSpec.m` for an example. 58 | 59 | ## Core Members 60 | 61 | If a few of your pull requests have been merged, and you'd like a 62 | controlling stake in the project, file an issue asking for write access 63 | to the repository. 64 | 65 | ### Code of Conduct 66 | 67 | Your conduct as a core member is your own responsibility, but here are 68 | some "ground rules": 69 | 70 | - Feel free to push whatever you want to master, and (if you have 71 | ownership permissions) to create any repositories you'd like. 72 | 73 | Ideally, however, all changes should be submitted as GitHub pull 74 | requests. No one should merge their own pull request, unless no 75 | other core members respond for at least a few days. 76 | 77 | Pull requests should be issued from personal forks. The Quick repo 78 | should be reserved for long-running feature branches. 79 | 80 | If you'd like to create a new repository, it'd be nice if you created 81 | a GitHub issue and gathered some feedback first. 82 | 83 | - It'd be awesome if you could review, provide feedback on, and close 84 | issues or pull requests submitted to the project. Please provide kind, 85 | constructive feedback. Please don't be sarcastic or snarky. 86 | 87 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick Templates/Quick Spec Class.xctemplate/Objective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | QuickSpecBegin(___FILEBASENAMEASIDENTIFIER___) 5 | 6 | QuickSpecEnd 7 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick Templates/Quick Spec Class.xctemplate/Swift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | 4 | class ___FILEBASENAMEASIDENTIFIER___: QuickSpec { 5 | override func spec() { 6 | 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick Templates/Quick Spec Class.xctemplate/TemplateIcon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatashaTheRobot/DependencyInjectionSwiftExample/0f04224f7a13c33741a755708aeb8b6b12e292db/Vendor/Quick/Quick Templates/Quick Spec Class.xctemplate/TemplateIcon.icns -------------------------------------------------------------------------------- /Vendor/Quick/Quick Templates/Quick Spec Class.xctemplate/TemplateInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Kind 6 | Xcode.IDEKit.TextSubstitutionFileTemplateKind 7 | Description 8 | A class implementing a Quick spec. 9 | Summary 10 | A class implementing a Quick spec 11 | SortOrder 12 | 1 13 | BuildableType 14 | Test 15 | DefaultCompletionName 16 | Spec 17 | Options 18 | 19 | 20 | Description 21 | Name of the Quick spec class 22 | Identifier 23 | productName 24 | Name 25 | Spec Name: 26 | NotPersisted 27 | 28 | Required 29 | 30 | Type 31 | text 32 | 33 | 34 | AllowedTypes 35 | 36 | Swift 37 | 38 | public.swift-source 39 | 40 | Objective-C 41 | 42 | public.objective-c-source 43 | public.objective-c-plus-plus-source 44 | 45 | 46 | Default 47 | Swift 48 | Description 49 | The implementation language 50 | Identifier 51 | languageChoice 52 | MainTemplateFiles 53 | 54 | Objective-C 55 | ___FILEBASENAME___.m 56 | Swift 57 | ___FILEBASENAME___.swift 58 | 59 | Name 60 | Language: 61 | Required 62 | Yes 63 | Type 64 | popup 65 | Values 66 | 67 | Swift 68 | Objective-C 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "Quick" 3 | s.version = "0.2.0" 4 | s.summary = "The Swift (and Objective-C) testing framework." 5 | 6 | s.description = <<-DESC 7 | Quick is a behavior-driven development framework for Swift and Objective-C. Inspired by RSpec, Specta, and Ginkgo. 8 | DESC 9 | 10 | s.homepage = "https://github.com/Quick/Quick" 11 | s.license = { :type => "Apache 2.0", :file => "LICENSE" } 12 | 13 | s.author = "Quick Contributors" 14 | s.ios.deployment_target = "8.0" 15 | s.osx.deployment_target = "10.10" 16 | 17 | s.source = { :git => "https://github.com/Quick/Quick.git", :tag => "v0.2.0" } 18 | s.source_files = "Quick", "Quick/**/*.{swift,h,m}" 19 | 20 | s.framework = "XCTest" 21 | end 22 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/Callsite.swift: -------------------------------------------------------------------------------- 1 | /** 2 | An object encapsulating the file and line number at which 3 | a particular example is defined. 4 | */ 5 | @objc final public class Callsite: Equatable { 6 | /** 7 | The absolute path of the file in which an example is defined. 8 | */ 9 | public let file: String 10 | 11 | /** 12 | The line number on which an example is defined. 13 | */ 14 | public let line: Int 15 | 16 | internal init(file: String, line: Int) { 17 | self.file = file 18 | self.line = line 19 | } 20 | } 21 | 22 | /** 23 | Returns a boolean indicating whether two Callsite objects are equal. 24 | If two callsites are in the same file and on the same line, they must be equal. 25 | */ 26 | public func ==(lhs: Callsite, rhs: Callsite) -> Bool { 27 | return lhs.file == rhs.file && lhs.line == rhs.line 28 | } 29 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/Configuration/QuickConfiguration.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class Configuration; 4 | 5 | /** 6 | Subclass QuickConfiguration and override the +[QuickConfiguration configure:] 7 | method in order to configure how Quick behaves when running specs, or to define 8 | shared examples that are used across spec files. 9 | */ 10 | @interface QuickConfiguration : NSObject 11 | 12 | /** 13 | This method is executed on each subclass of this class before Quick runs 14 | any examples. You may override this method on as many subclasses as you like, but 15 | there is no guarantee as to the order in which these methods are executed. 16 | 17 | You can override this method in order to: 18 | 19 | 1. Configure how Quick behaves, by modifying properties on the Configuration object. 20 | Setting the same properties in several methods has undefined behavior. 21 | 22 | 2. Define shared examples using `sharedExamples`. 23 | 24 | @param configuration A mutable object that is used to configure how Quick behaves on 25 | a framework level. For details on all the options, see the 26 | documentation in Configuration.swift. 27 | */ 28 | + (void)configure:(Configuration *)configuration; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/Configuration/QuickConfiguration.m: -------------------------------------------------------------------------------- 1 | #import "QuickConfiguration.h" 2 | #import 3 | #import 4 | 5 | typedef void (^QCKClassEnumerationBlock)(Class klass); 6 | 7 | /** 8 | Finds all direct subclasses of the given class and passes them to the block provided. 9 | The classes are iterated over in the order that objc_getClassList returns them. 10 | 11 | @param klass The base class to find subclasses of. 12 | @param block A block that takes a Class. This block will be executed once for each subclass of klass. 13 | */ 14 | void qck_enumerateSubclasses(Class klass, QCKClassEnumerationBlock block) { 15 | Class *classes = NULL; 16 | int classesCount = objc_getClassList(NULL, 0); 17 | 18 | if (classesCount > 0) { 19 | classes = (Class *)calloc(sizeof(Class), classesCount); 20 | classesCount = objc_getClassList(classes, classesCount); 21 | 22 | Class subclass, superclass; 23 | for(int i = 0; i < classesCount; i++) { 24 | subclass = classes[i]; 25 | superclass = class_getSuperclass(subclass); 26 | if (superclass == klass && block) { 27 | block(subclass); 28 | } 29 | } 30 | 31 | free(classes); 32 | } 33 | } 34 | 35 | @implementation QuickConfiguration 36 | 37 | #pragma mark - Object Lifecycle 38 | 39 | /** 40 | QuickConfiguration is not meant to be instantiated; it merely provides a hook 41 | for users to configure how Quick behaves. Raise an exception if an instance of 42 | QuickConfiguration is created. 43 | */ 44 | - (instancetype)init { 45 | NSString *className = NSStringFromClass([self class]); 46 | NSString *selectorName = NSStringFromSelector(@selector(configure:)); 47 | [NSException raise:NSInternalInconsistencyException 48 | format:@"%@ is not meant to be instantiated; " 49 | @"subclass %@ and override %@ to configure Quick.", 50 | className, className, selectorName]; 51 | return nil; 52 | } 53 | 54 | #pragma mark - NSObject Overrides 55 | 56 | /** 57 | Hook into when QuickConfiguration is initialized in the runtime in order to 58 | call +[QuickConfiguration configure:] on each of its subclasses. 59 | */ 60 | + (void)initialize { 61 | // Only enumerate over the subclasses of QuickConfiguration, not any of its subclasses. 62 | if ([self class] == [QuickConfiguration class]) { 63 | 64 | // Only enumerate over subclasses once, even if +[QuickConfiguration initialize] 65 | // were to be called several times. This is necessary because +[QuickSpec initialize] 66 | // manually calls +[QuickConfiguration initialize]. 67 | static dispatch_once_t onceToken; 68 | dispatch_once(&onceToken, ^{ 69 | qck_enumerateSubclasses([QuickConfiguration class], ^(__unsafe_unretained Class klass) { 70 | [[World sharedWorld] configure:^(Configuration *configuration) { 71 | [klass configure:configuration]; 72 | }]; 73 | }); 74 | [[World sharedWorld] finalizeConfiguration]; 75 | }); 76 | } 77 | } 78 | 79 | #pragma mark - Public Interface 80 | 81 | + (void)configure:(Configuration *)configuration { } 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/DSL/QCKDSL.m: -------------------------------------------------------------------------------- 1 | #import "QCKDSL.h" 2 | #import 3 | 4 | void qck_beforeSuite(QCKDSLEmptyBlock closure) { 5 | [[World sharedWorld] beforeSuite:closure]; 6 | } 7 | 8 | void qck_afterSuite(QCKDSLEmptyBlock closure) { 9 | [[World sharedWorld] afterSuite:closure]; 10 | } 11 | 12 | void qck_sharedExamples(NSString *name, QCKDSLSharedExampleBlock closure) { 13 | [[World sharedWorld] sharedExamples:name closure:closure]; 14 | } 15 | 16 | void qck_describe(NSString *description, QCKDSLEmptyBlock closure) { 17 | [[World sharedWorld] describe:description closure:closure flags:@{}]; 18 | } 19 | 20 | void qck_context(NSString *description, QCKDSLEmptyBlock closure) { 21 | qck_describe(description, closure); 22 | } 23 | 24 | void qck_beforeEach(QCKDSLEmptyBlock closure) { 25 | [[World sharedWorld] beforeEach:closure]; 26 | } 27 | 28 | void qck_afterEach(QCKDSLEmptyBlock closure) { 29 | [[World sharedWorld] afterEach:closure]; 30 | } 31 | 32 | QCKItBlock qck_it_builder(NSDictionary *flags, NSString *file, NSUInteger line) { 33 | return ^(NSString *description, QCKDSLEmptyBlock closure) { 34 | [[World sharedWorld] itWithDescription:description 35 | flags:flags 36 | file:file 37 | line:line 38 | closure:closure]; 39 | }; 40 | } 41 | 42 | QCKItBehavesLikeBlock qck_itBehavesLike_builder(NSDictionary *flags, NSString *file, NSUInteger line) { 43 | return ^(NSString *name, QCKDSLSharedExampleContext context) { 44 | [[World sharedWorld] itBehavesLikeSharedExampleNamed:name 45 | sharedExampleContext:context 46 | flags:flags 47 | file:file 48 | line:line]; 49 | }; 50 | } 51 | 52 | void qck_pending(NSString *description, QCKDSLEmptyBlock closure) { 53 | [[World sharedWorld] pending:description closure:closure]; 54 | } 55 | 56 | void qck_xdescribe(NSString *description, QCKDSLEmptyBlock closure) { 57 | [[World sharedWorld] xdescribe:description closure:closure flags:@{}]; 58 | } 59 | 60 | void qck_xcontext(NSString *description, QCKDSLEmptyBlock closure) { 61 | qck_xdescribe(description, closure); 62 | } 63 | 64 | void qck_fdescribe(NSString *description, QCKDSLEmptyBlock closure) { 65 | [[World sharedWorld] fdescribe:description closure:closure flags:@{}]; 66 | } 67 | 68 | void qck_fcontext(NSString *description, QCKDSLEmptyBlock closure) { 69 | qck_fdescribe(description, closure); 70 | } 71 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/ExampleGroup.swift: -------------------------------------------------------------------------------- 1 | /** 2 | Example groups are logical groupings of examples, defined with 3 | the `describe` and `context` functions. Example groups can share 4 | setup and teardown code. 5 | */ 6 | @objc final public class ExampleGroup { 7 | weak internal var parent: ExampleGroup? 8 | internal let hooks = ExampleHooks() 9 | 10 | private let description: String 11 | private let flags: FilterFlags 12 | private let isInternalRootExampleGroup: Bool 13 | private var childGroups = [ExampleGroup]() 14 | private var childExamples = [Example]() 15 | 16 | internal init(description: String, flags: FilterFlags, isInternalRootExampleGroup: Bool = false) { 17 | self.description = description 18 | self.flags = flags 19 | self.isInternalRootExampleGroup = isInternalRootExampleGroup 20 | } 21 | 22 | /** 23 | Returns a list of examples that belong to this example group, 24 | or to any of its descendant example groups. 25 | */ 26 | public var examples: [Example] { 27 | var examples = childExamples 28 | for group in childGroups { 29 | examples.extend(group.examples) 30 | } 31 | return examples 32 | } 33 | 34 | internal var name: String? { 35 | if let parent = parent { 36 | switch(parent.name) { 37 | case .Some(let name): return "\(name), \(description)" 38 | case .None: return description 39 | } 40 | } else { 41 | return isInternalRootExampleGroup ? nil : description 42 | } 43 | } 44 | 45 | internal var filterFlags: FilterFlags { 46 | var aggregateFlags = flags 47 | walkUp() { (group: ExampleGroup) -> () in 48 | for (key, value) in group.flags { 49 | aggregateFlags[key] = value 50 | } 51 | } 52 | return aggregateFlags 53 | } 54 | 55 | internal var befores: [BeforeExampleWithMetadataClosure] { 56 | var closures = hooks.befores.reverse() 57 | walkUp() { (group: ExampleGroup) -> () in 58 | closures.extend(group.hooks.befores.reverse()) 59 | } 60 | return closures.reverse() 61 | } 62 | 63 | internal var afters: [AfterExampleWithMetadataClosure] { 64 | var closures = hooks.afters 65 | walkUp() { (group: ExampleGroup) -> () in 66 | closures.extend(group.hooks.afters) 67 | } 68 | return closures 69 | } 70 | 71 | internal func walkDownExamples(callback: (example: Example) -> ()) { 72 | for example in childExamples { 73 | callback(example: example) 74 | } 75 | for group in childGroups { 76 | group.walkDownExamples(callback) 77 | } 78 | } 79 | 80 | internal func appendExampleGroup(group: ExampleGroup) { 81 | group.parent = self 82 | childGroups.append(group) 83 | } 84 | 85 | internal func appendExample(example: Example) { 86 | example.group = self 87 | childExamples.append(example) 88 | } 89 | 90 | private func walkUp(callback: (group: ExampleGroup) -> ()) { 91 | var group = self 92 | while let parent = group.parent { 93 | callback(group: parent) 94 | group = parent 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/ExampleMetadata.swift: -------------------------------------------------------------------------------- 1 | /** 2 | A class that encapsulates information about an example, 3 | including the index at which the example was executed, as 4 | well as the example itself. 5 | */ 6 | @objc final public class ExampleMetadata { 7 | /** 8 | The example for which this metadata was collected. 9 | */ 10 | public let example: Example 11 | 12 | /** 13 | The index at which this example was executed in the 14 | test suite. 15 | */ 16 | public let exampleIndex: Int 17 | 18 | internal init(example: Example, exampleIndex: Int) { 19 | self.example = example 20 | self.exampleIndex = exampleIndex 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/Failure.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | @objc final class Failure { 4 | let callsite: Callsite 5 | let exception: NSException 6 | 7 | init(exception: NSException, callsite: Callsite) { 8 | self.exception = exception 9 | self.callsite = callsite 10 | } 11 | 12 | @objc(failureWithException:callsite:) 13 | class func failure(exception: NSException, callsite: Callsite) -> Failure { 14 | return Failure(exception: exception, callsite: callsite) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/Filter.swift: -------------------------------------------------------------------------------- 1 | /** 2 | A mapping of string keys to booleans that can be used to 3 | filter examples or example groups. For example, a "focused" 4 | example would have the flags [Focused: true]. 5 | */ 6 | public typealias FilterFlags = [String: Bool] 7 | 8 | /** 9 | A namespace for filter flag keys, defined primarily to make the 10 | keys available in Objective-C. 11 | */ 12 | @objc(QCKFilter) final public class Filter { 13 | /** 14 | Example and example groups with [Focused: true] are included in test runs, 15 | excluding all other examples without this flag. Use this to only run one or 16 | two tests that you're currently focusing on. 17 | */ 18 | public class var focused: String { 19 | return "focused" 20 | } 21 | 22 | /** 23 | Example and example groups with [Pending: true] are excluded from test runs. 24 | Use this to temporarily suspend examples that you know do not pass yet. 25 | */ 26 | public class var pending: String { 27 | return "pending" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/Hooks/Closures.swift: -------------------------------------------------------------------------------- 1 | // MARK: Example Hooks 2 | 3 | /** 4 | A closure executed before an example is run. 5 | */ 6 | public typealias BeforeExampleClosure = () -> () 7 | 8 | /** 9 | A closure executed before an example is run. The closure is given example metadata, 10 | which contains information about the example that is about to be run. 11 | */ 12 | public typealias BeforeExampleWithMetadataClosure = (exampleMetadata: ExampleMetadata) -> () 13 | 14 | /** 15 | A closure executed after an example is run. 16 | */ 17 | public typealias AfterExampleClosure = BeforeExampleClosure 18 | 19 | /** 20 | A closure executed after an example is run. The closure is given example metadata, 21 | which contains information about the example that has just finished running. 22 | */ 23 | public typealias AfterExampleWithMetadataClosure = BeforeExampleWithMetadataClosure 24 | 25 | // MARK: Suite Hooks 26 | 27 | /** 28 | A closure executed before any examples are run. 29 | */ 30 | public typealias BeforeSuiteClosure = () -> () 31 | 32 | /** 33 | A closure executed after all examples have finished running. 34 | */ 35 | public typealias AfterSuiteClosure = BeforeSuiteClosure 36 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/Hooks/ExampleHooks.swift: -------------------------------------------------------------------------------- 1 | /** 2 | A container for closures to be executed before and after each example. 3 | */ 4 | final internal class ExampleHooks { 5 | 6 | internal var befores: [BeforeExampleWithMetadataClosure] = [] 7 | internal var afters: [AfterExampleWithMetadataClosure] = [] 8 | 9 | internal func appendBefore(closure: BeforeExampleWithMetadataClosure) { 10 | befores.append(closure) 11 | } 12 | 13 | internal func appendBefore(closure: BeforeExampleClosure) { 14 | befores.append { (exampleMetadata: ExampleMetadata) in closure() } 15 | } 16 | 17 | internal func appendAfter(closure: AfterExampleWithMetadataClosure) { 18 | afters.append(closure) 19 | } 20 | 21 | internal func appendAfter(closure: AfterExampleClosure) { 22 | afters.append { (exampleMetadata: ExampleMetadata) in closure() } 23 | } 24 | 25 | internal func executeBefores(exampleMetadata: ExampleMetadata) { 26 | for before in befores { 27 | before(exampleMetadata: exampleMetadata) 28 | } 29 | } 30 | 31 | internal func executeAfters(exampleMetadata: ExampleMetadata) { 32 | for after in afters { 33 | after(exampleMetadata: exampleMetadata) 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/Hooks/SuiteHooks.swift: -------------------------------------------------------------------------------- 1 | /** 2 | A container for closures to be executed before and after all examples. 3 | */ 4 | final internal class SuiteHooks { 5 | internal var befores: [BeforeSuiteClosure] = [] 6 | internal var beforesAlreadyExecuted = false 7 | 8 | internal var afters: [AfterSuiteClosure] = [] 9 | internal var aftersAlreadyExecuted = false 10 | 11 | internal func appendBefore(closure: BeforeSuiteClosure) { 12 | befores.append(closure) 13 | } 14 | 15 | internal func appendAfter(closure: AfterSuiteClosure) { 16 | afters.append(closure) 17 | } 18 | 19 | internal func executeBefores() { 20 | assert(!beforesAlreadyExecuted) 21 | for before in befores { 22 | before() 23 | } 24 | beforesAlreadyExecuted = true 25 | } 26 | 27 | internal func executeAfters() { 28 | assert(!aftersAlreadyExecuted) 29 | for after in afters { 30 | after() 31 | } 32 | aftersAlreadyExecuted = true 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | io.quick.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSHumanReadableCopyright 24 | Copyright © 2014 - present, Quick Team. All rights reserved. 25 | NSPrincipalClass 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/NSString+QCKSelectorName.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | /** 4 | QuickSpec converts example names into test methods. 5 | Those test methods need valid selector names, which means no whitespace, 6 | control characters, etc. This category gives NSString objects an easy way 7 | to replace those illegal characters with underscores. 8 | */ 9 | @interface NSString (QCKSelectorName) 10 | 11 | /** 12 | Returns a string with underscores in place of all characters that cannot 13 | be included in a selector (SEL) name. 14 | */ 15 | @property (nonatomic, readonly) NSString *qck_selectorName; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/NSString+QCKSelectorName.m: -------------------------------------------------------------------------------- 1 | #import "NSString+QCKSelectorName.h" 2 | 3 | @implementation NSString (QCKSelectorName) 4 | 5 | - (NSString *)qck_selectorName { 6 | static NSMutableCharacterSet *invalidCharacters = nil; 7 | static dispatch_once_t onceToken; 8 | dispatch_once(&onceToken, ^{ 9 | invalidCharacters = [NSMutableCharacterSet new]; 10 | 11 | NSCharacterSet *whitespaceCharacterSet = [NSCharacterSet whitespaceCharacterSet]; 12 | NSCharacterSet *newlineCharacterSet = [NSCharacterSet newlineCharacterSet]; 13 | NSCharacterSet *illegalCharacterSet = [NSCharacterSet illegalCharacterSet]; 14 | NSCharacterSet *controlCharacterSet = [NSCharacterSet controlCharacterSet]; 15 | NSCharacterSet *punctuationCharacterSet = [NSCharacterSet punctuationCharacterSet]; 16 | NSCharacterSet *nonBaseCharacterSet = [NSCharacterSet nonBaseCharacterSet]; 17 | NSCharacterSet *symbolCharacterSet = [NSCharacterSet symbolCharacterSet]; 18 | 19 | [invalidCharacters formUnionWithCharacterSet:whitespaceCharacterSet]; 20 | [invalidCharacters formUnionWithCharacterSet:newlineCharacterSet]; 21 | [invalidCharacters formUnionWithCharacterSet:illegalCharacterSet]; 22 | [invalidCharacters formUnionWithCharacterSet:controlCharacterSet]; 23 | [invalidCharacters formUnionWithCharacterSet:punctuationCharacterSet]; 24 | [invalidCharacters formUnionWithCharacterSet:nonBaseCharacterSet]; 25 | [invalidCharacters formUnionWithCharacterSet:symbolCharacterSet]; 26 | }); 27 | 28 | NSArray *validComponents = [self componentsSeparatedByCharactersInSet:invalidCharacters]; 29 | 30 | return [validComponents componentsJoinedByString:@"_"]; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/Quick.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | //! Project version number for Quick. 4 | FOUNDATION_EXPORT double QuickVersionNumber; 5 | 6 | //! Project version string for Quick. 7 | FOUNDATION_EXPORT const unsigned char QuickVersionString[]; 8 | 9 | // In this header, you should import all the public headers of your framework using statements like #import 10 | 11 | #import 12 | #import 13 | #import 14 | -------------------------------------------------------------------------------- /Vendor/Quick/Quick/QuickSpec.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | /** 4 | QuickSpec is a base class all specs written in Quick inherit from. 5 | They need to inherit from QuickSpec, a subclass of XCTestCase, in 6 | order to be discovered by the XCTest framework. 7 | 8 | XCTest automatically compiles a list of XCTestCase subclasses included 9 | in the test target. It iterates over each class in that list, and creates 10 | a new instance of that class for each test method. It then creates an 11 | "invocation" to execute that test method. The invocation is an instance of 12 | NSInvocation, which represents a single message send in Objective-C. 13 | The invocation is set on the XCTestCase instance, and the test is run. 14 | 15 | Most of the code in QuickSpec is dedicated to hooking into XCTest events. 16 | First, when the spec is first loaded and before it is sent any messages, 17 | the +[NSObject initialize] method is called. QuickSpec overrides this method 18 | to call +[QuickSpec spec]. This builds the example group stacks and 19 | registers them with Quick.World, a global register of examples. 20 | 21 | Then, XCTest queries QuickSpec for a list of test methods. Normally, XCTest 22 | automatically finds all methods whose selectors begin with the string "test". 23 | However, QuickSpec overrides this default behavior by implementing the 24 | +[XCTestCase testInvocations] method. This method iterates over each example 25 | registered in Quick.World, defines a new method for that example, and 26 | returns an invocation to call that method to XCTest. Those invocations are 27 | the tests that are run by XCTest. Their selector names are displayed in 28 | the Xcode test navigation bar. 29 | */ 30 | @interface QuickSpec : XCTestCase 31 | 32 | /** 33 | Override this method in your spec to define a set of example groups 34 | and examples. 35 | 36 | override class func spec() { 37 | describe("winter") { 38 | it("is coming") { 39 | // ... 40 | } 41 | } 42 | } 43 | 44 | See DSL.swift for more information on what syntax is available. 45 | */ 46 | - (void)spec; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickFocusedTests/FocusedTests+ObjC.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | #import "QCKSpecRunner.h" 6 | 7 | QuickConfigurationBegin(FunctionalTests_SharedExamplesConfiguration) 8 | 9 | + (void)configure:(Configuration *)configuration { 10 | sharedExamples(@"two passing shared examples (Objective-C)", ^(QCKDSLSharedExampleContext exampleContext) { 11 | it(@"has an example that passes (4)", ^{}); 12 | it(@"has another example that passes (5)", ^{}); 13 | }); 14 | } 15 | 16 | QuickConfigurationEnd 17 | 18 | QuickSpecBegin(FunctionalTests_FocusedSpec_Focused) 19 | 20 | it(@"has an unfocused example that fails, but is never run", ^{ XCTFail(); }); 21 | fit(@"has a focused example that passes (1)", ^{}); 22 | 23 | fdescribe(@"a focused example group", ^{ 24 | it(@"has an example that is not focused, but will be run, and passes (2)", ^{}); 25 | fit(@"has a focused example that passes (3)", ^{}); 26 | }); 27 | 28 | fitBehavesLike(@"two passing shared examples (Objective-C)", ^NSDictionary *{ return @{}; }); 29 | 30 | QuickSpecEnd 31 | 32 | QuickSpecBegin(FunctionalTests_FocusedSpec_Unfocused) 33 | 34 | it(@"has an unfocused example thay fails, but is never run", ^{ XCTFail(); }); 35 | 36 | describe(@"an unfocused example group that is never run", ^{ 37 | beforeEach(^{ [NSException raise:NSInternalInconsistencyException format:nil]; }); 38 | it(@"has an example that fails, but is never run", ^{ XCTFail(); }); 39 | }); 40 | 41 | QuickSpecEnd 42 | 43 | @interface FocusedTests: XCTestCase 44 | @end 45 | 46 | @implementation FocusedTests 47 | 48 | - (void)testOnlyFocusedExamplesAreExecuted { 49 | XCTestRun *result = qck_runSpecs(@[ 50 | [FunctionalTests_FocusedSpec_Focused class], 51 | [FunctionalTests_FocusedSpec_Unfocused class] 52 | ]); 53 | XCTAssertEqual(result.executionCount, 5); 54 | } 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickFocusedTests/FocusedTests.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | import XCTest 4 | 5 | class FunctionalTests_FocusedSpec_SharedExamplesConfiguration: QuickConfiguration { 6 | override class func configure(configuration: Configuration) { 7 | sharedExamples("two passing shared examples") { 8 | it("has an example that passes (4)") {} 9 | it("has another example that passes (5)") {} 10 | } 11 | } 12 | } 13 | 14 | class FunctionalTests_FocusedSpec_Focused: QuickSpec { 15 | override func spec() { 16 | it("has an unfocused example that fails, but is never run") { fail() } 17 | fit("has a focused example that passes (1)") {} 18 | 19 | fdescribe("a focused example group") { 20 | it("has an example that is not focused, but will be run, and passes (2)") {} 21 | fit("has a focused example that passes (3)") {} 22 | } 23 | 24 | // TODO: Port fitBehavesLike to Swift. 25 | itBehavesLike("two passing shared examples", flags: [Filter.focused: true]) 26 | } 27 | } 28 | 29 | class FunctionalTests_FocusedSpec_Unfocused: QuickSpec { 30 | override func spec() { 31 | it("has an unfocused example that fails, but is never run") { fail() } 32 | 33 | describe("an unfocused example group that is never run") { 34 | beforeEach { assert(false) } 35 | it("has an example that fails, but is never run") { fail() } 36 | } 37 | } 38 | } 39 | 40 | class FocusedTests: XCTestCase { 41 | func testOnlyFocusedExamplesAreExecuted() { 42 | let result = qck_runSpecs([ 43 | FunctionalTests_FocusedSpec_Focused.classForCoder(), 44 | FunctionalTests_FocusedSpec_Unfocused.classForCoder() 45 | ]) 46 | XCTAssertEqual(result.executionCount, 5 as UInt) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickFocusedTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | io.quick.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/ExampleMetadataFunctionalTests.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | 4 | class ExampleMetadataFunctionalTestsSpec: QuickSpec { 5 | override func spec() { 6 | var currentExampleName = "" 7 | var lastExampleName = "" 8 | 9 | beforeEach { (exampleMetadata: ExampleMetadata) -> () in 10 | currentExampleName = exampleMetadata.example.name 11 | } 12 | 13 | afterEach { (exampleMetadata: ExampleMetadata) -> () in 14 | lastExampleName = exampleMetadata.example.name 15 | } 16 | 17 | it("calls beforeEach with the metadata for the first example") { 18 | expect(currentExampleName).to(contain("calls beforeEach with the metadata")) 19 | } 20 | 21 | it("calls afterEach with the metadata for the first example") { 22 | expect(lastExampleName).to(contain("calls beforeEach with the metadata")) 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/Fixtures/FunctionalTests_SharedExamplesTests_SharedExamples.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | 4 | class FunctionalTests_SharedExamplesTests_SharedExamples: QuickConfiguration { 5 | override class func configure(configuration: Configuration) { 6 | sharedExamples("a group of three shared examples") { 7 | it("passes once") { expect(true).to(beTruthy()) } 8 | it("passes twice") { expect(true).to(beTruthy()) } 9 | it("passes three times") { expect(true).to(beTruthy()) } 10 | } 11 | 12 | sharedExamples("shared examples that take a context") { (sharedExampleContext: SharedExampleContext) in 13 | it("is passed the correct parameters via the context") { 14 | let callsite = sharedExampleContext()["callsite"] as String 15 | expect(callsite).to(equal("SharedExamplesSpec")) 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/Fixtures/Person.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class Person: NSObject { 4 | var isHappy = true 5 | var isHungry = false 6 | var isSatisfied = false 7 | var hopes = ["winning the lottery", "going on a blimp ride"] 8 | var smalltalk = "Come here often?" 9 | var valediction = "See you soon." 10 | 11 | var greeting: String { 12 | get { 13 | if isHappy { 14 | return "Hello!" 15 | } else { 16 | return "Oh, hi." 17 | } 18 | } 19 | } 20 | 21 | func eatChineseFood() { 22 | let after = dispatch_time(DISPATCH_TIME_NOW, 500000000) 23 | dispatch_after(after, dispatch_get_main_queue()) { 24 | self.isHungry = true 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/Fixtures/Poet.swift: -------------------------------------------------------------------------------- 1 | class Poet: Person { 2 | override var greeting: String { 3 | get { 4 | if isHappy { 5 | return "Oh, joyous day!" 6 | } else { 7 | return "Woe is me!" 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests+ObjC.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | QuickConfigurationBegin(FunctionalTestsObjCSharedExampleGroups) 5 | 6 | + (void)configure:(Configuration *)configuration { 7 | sharedExamples(@"a truthy value", ^(QCKDSLSharedExampleContext sharedExampleContext) { 8 | __block NSNumber *value = nil; 9 | beforeEach(^{ 10 | value = sharedExampleContext()[@"value"]; 11 | }); 12 | 13 | it(@"is true", ^{ 14 | expect(value).to(beTruthy()); 15 | }); 16 | }); 17 | } 18 | 19 | QuickConfigurationEnd 20 | 21 | static BOOL beforeSuiteExecuted_afterSuiteNotYetExecuted = NO; 22 | 23 | QuickSpecBegin(FunctionalTestsObjC) 24 | 25 | beforeSuite(^{ 26 | beforeSuiteExecuted_afterSuiteNotYetExecuted = YES; 27 | }); 28 | 29 | afterSuite(^{ 30 | beforeSuiteExecuted_afterSuiteNotYetExecuted = NO; 31 | }); 32 | 33 | describe(@"a describe block", ^{ 34 | it(@"contains an it block", ^{ 35 | expect(@(beforeSuiteExecuted_afterSuiteNotYetExecuted)).to(beTruthy()); 36 | }); 37 | 38 | itBehavesLike(@"a truthy value", ^{ 39 | return @{ @"value": @YES }; 40 | }); 41 | 42 | pending(@"a pending block", ^{ 43 | it(@"contains a failing it block", ^{ 44 | expect(@NO).to(beTruthy()); 45 | }); 46 | }); 47 | 48 | xdescribe(@"a pending (shorthand) describe block", ^{ 49 | it(@"contains a failing it block", ^{ 50 | expect(@NO).to(beTruthy()); 51 | }); 52 | }); 53 | 54 | xcontext(@"a pending (shorthand) context block", ^{ 55 | it(@"contains a failing it block", ^{ 56 | expect(@NO).to(beTruthy()); 57 | }); 58 | }); 59 | 60 | xit(@"contains a pending (shorthand) it block", ^{ 61 | expect(@NO).to(beTruthy()); 62 | }); 63 | }); 64 | 65 | QuickSpecEnd 66 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/AfterEachTests+ObjC.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | #import "QCKSpecRunner.h" 6 | 7 | typedef NS_ENUM(NSUInteger, AfterEachType) { 8 | OuterOne, 9 | OuterTwo, 10 | OuterThree, 11 | InnerOne, 12 | InnerTwo, 13 | NoExamples, 14 | }; 15 | 16 | static NSMutableArray *afterEachOrder; 17 | 18 | QuickSpecBegin(FunctionalTests_AfterEachSpec) 19 | 20 | afterEach(^{ [afterEachOrder addObject:@(OuterOne)]; }); 21 | afterEach(^{ [afterEachOrder addObject:@(OuterTwo)]; }); 22 | afterEach(^{ [afterEachOrder addObject:@(OuterThree)]; }); 23 | 24 | it(@"executes the outer afterEach closures once, but not before this closure [1]", ^{ 25 | expect(afterEachOrder).to(equal(@[])); 26 | }); 27 | 28 | it(@"executes the outer afterEach closures a second time, but not before this closure [2]", ^{ 29 | expect(afterEachOrder).to(equal(@[@(OuterOne), @(OuterTwo), @(OuterThree)])); 30 | }); 31 | 32 | context(@"when there are nested afterEach", ^{ 33 | afterEach(^{ [afterEachOrder addObject:@(InnerOne)]; }); 34 | afterEach(^{ [afterEachOrder addObject:@(InnerTwo)]; }); 35 | 36 | it(@"executes the outer and inner afterEach closures, but not before this closure [3]", ^{ 37 | // The afterEach for the previous two examples should have been run. 38 | // The list should contain the afterEach for those example, executed from top to bottom. 39 | expect(afterEachOrder).to(equal(@[ 40 | @(OuterOne), @(OuterTwo), @(OuterThree), 41 | @(OuterOne), @(OuterTwo), @(OuterThree), 42 | ])); 43 | }); 44 | }); 45 | 46 | context(@"when there are nested afterEach without examples", ^{ 47 | afterEach(^{ [afterEachOrder addObject:@(NoExamples)]; }); 48 | }); 49 | 50 | QuickSpecEnd 51 | 52 | @interface AfterEachTests : XCTestCase; @end 53 | 54 | @implementation AfterEachTests 55 | 56 | - (void)setUp { 57 | [super setUp]; 58 | afterEachOrder = [NSMutableArray array]; 59 | } 60 | 61 | - (void)tearDown { 62 | afterEachOrder = [NSMutableArray array]; 63 | [super tearDown]; 64 | } 65 | 66 | - (void)testAfterEachIsExecutedInTheCorrectOrder { 67 | qck_runSpec([FunctionalTests_AfterEachSpec class]); 68 | NSArray *expectedOrder = @[ 69 | // [1] The outer afterEach closures are executed from top to bottom. 70 | @(OuterOne), @(OuterTwo), @(OuterThree), 71 | // [2] The outer afterEach closures are executed from top to bottom. 72 | @(OuterOne), @(OuterTwo), @(OuterThree), 73 | // [3] The outer afterEach closures are executed from top to bottom, 74 | // then the outer afterEach closures are executed from top to bottom. 75 | @(InnerOne), @(InnerTwo), @(OuterOne), @(OuterTwo), @(OuterThree), 76 | ]; 77 | 78 | XCTAssertEqualObjects(afterEachOrder, expectedOrder); 79 | } 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/AfterSuiteTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Quick 3 | import Nimble 4 | 5 | var afterSuiteWasExecuted = false 6 | 7 | class FunctionalTests_AfterSuite_AfterSuiteSpec: QuickSpec { 8 | override func spec() { 9 | afterSuite { 10 | afterSuiteWasExecuted = true 11 | } 12 | } 13 | } 14 | 15 | class FunctionalTests_AfterSuite_Spec: QuickSpec { 16 | override func spec() { 17 | it("is executed before afterSuite") { 18 | expect(afterSuiteWasExecuted).to(beFalsy()) 19 | } 20 | } 21 | } 22 | 23 | class AfterSuiteTests: XCTestCase { 24 | func testAfterSuiteIsNotExecutedBeforeAnyExamples() { 25 | // Execute the spec with an assertion after the one with an afterSuite. 26 | let specs = NSArray(objects: FunctionalTests_AfterSuite_AfterSuiteSpec.classForCoder(), 27 | FunctionalTests_AfterSuite_Spec.classForCoder()) 28 | let result = qck_runSpecs(specs) 29 | 30 | // Although this ensures that afterSuite is not called before any 31 | // examples, it doesn't test that it's ever called in the first place. 32 | XCTAssert(result.hasSucceeded) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/BeforeEachTests+ObjC.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import "QCKSpecRunner.h" 5 | 6 | typedef NS_ENUM(NSUInteger, BeforeEachType) { 7 | OuterOne, 8 | OuterTwo, 9 | InnerOne, 10 | InnerTwo, 11 | InnerThree, 12 | NoExamples, 13 | }; 14 | 15 | static NSMutableArray *beforeEachOrder; 16 | 17 | QuickSpecBegin(FunctionalTests_BeforeEachSpec) 18 | 19 | beforeEach(^{ [beforeEachOrder addObject:@(OuterOne)]; }); 20 | beforeEach(^{ [beforeEachOrder addObject:@(OuterTwo)]; }); 21 | 22 | it(@"executes the outer beforeEach closures once [1]", ^{}); 23 | it(@"executes the outer beforeEach closures a second time [2]", ^{}); 24 | 25 | context(@"when there are nested beforeEach", ^{ 26 | beforeEach(^{ [beforeEachOrder addObject:@(InnerOne)]; }); 27 | beforeEach(^{ [beforeEachOrder addObject:@(InnerTwo)]; }); 28 | beforeEach(^{ [beforeEachOrder addObject:@(InnerThree)]; }); 29 | 30 | it(@"executes the outer and inner beforeEach closures [3]", ^{}); 31 | }); 32 | 33 | context(@"when there are nested beforeEach without examples", ^{ 34 | beforeEach(^{ [beforeEachOrder addObject:@(NoExamples)]; }); 35 | }); 36 | 37 | QuickSpecEnd 38 | 39 | @interface BeforeEachTests : XCTestCase; @end 40 | 41 | @implementation BeforeEachTests 42 | 43 | - (void)setUp { 44 | beforeEachOrder = [NSMutableArray array]; 45 | [super setUp]; 46 | } 47 | 48 | - (void)tearDown { 49 | beforeEachOrder = [NSMutableArray array]; 50 | [super tearDown]; 51 | } 52 | 53 | - (void)testBeforeEachIsExecutedInTheCorrectOrder { 54 | qck_runSpec([FunctionalTests_BeforeEachSpec class]); 55 | NSArray *expectedOrder = @[ 56 | // [1] The outer beforeEach closures are executed from top to bottom. 57 | @(OuterOne), @(OuterTwo), 58 | // [2] The outer beforeEach closures are executed from top to bottom. 59 | @(OuterOne), @(OuterTwo), 60 | // [3] The outer beforeEach closures are executed from top to bottom, 61 | // then the inner beforeEach closures are executed from top to bottom. 62 | @(OuterOne), @(OuterTwo), @(InnerOne), @(InnerTwo), @(InnerThree), 63 | ]; 64 | 65 | XCTAssertEqualObjects(beforeEachOrder, expectedOrder); 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/BeforeEachTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Quick 3 | import Nimble 4 | 5 | private enum BeforeEachType { 6 | case OuterOne 7 | case OuterTwo 8 | case InnerOne 9 | case InnerTwo 10 | case InnerThree 11 | case NoExamples 12 | } 13 | 14 | private var beforeEachOrder = [BeforeEachType]() 15 | 16 | class FunctionalTests_BeforeEachSpec: QuickSpec { 17 | override func spec() { 18 | beforeEach { beforeEachOrder.append(BeforeEachType.OuterOne) } 19 | beforeEach { beforeEachOrder.append(BeforeEachType.OuterTwo) } 20 | 21 | it("executes the outer beforeEach closures once [1]") {} 22 | it("executes the outer beforeEach closures a second time [2]") {} 23 | 24 | context("when there are nested beforeEach") { 25 | beforeEach { beforeEachOrder.append(BeforeEachType.InnerOne) } 26 | beforeEach { beforeEachOrder.append(BeforeEachType.InnerTwo) } 27 | beforeEach { beforeEachOrder.append(BeforeEachType.InnerThree) } 28 | 29 | it("executes the outer and inner beforeEach closures [3]") {} 30 | } 31 | 32 | context("when there are nested beforeEach without examples") { 33 | beforeEach { beforeEachOrder.append(BeforeEachType.NoExamples) } 34 | } 35 | } 36 | } 37 | 38 | class BeforeEachTests: XCTestCase { 39 | override func setUp() { 40 | super.setUp() 41 | beforeEachOrder = [] 42 | } 43 | 44 | override func tearDown() { 45 | beforeEachOrder = [] 46 | super.tearDown() 47 | } 48 | 49 | func testBeforeEachIsExecutedInTheCorrectOrder() { 50 | qck_runSpec(FunctionalTests_BeforeEachSpec.classForCoder()) 51 | let expectedOrder = [ 52 | // [1] The outer beforeEach closures are executed from top to bottom. 53 | BeforeEachType.OuterOne, BeforeEachType.OuterTwo, 54 | // [2] The outer beforeEach closures are executed from top to bottom. 55 | BeforeEachType.OuterOne, BeforeEachType.OuterTwo, 56 | // [3] The outer beforeEach closures are executed from top to bottom, 57 | // then the inner beforeEach closures are executed from top to bottom. 58 | BeforeEachType.OuterOne, BeforeEachType.OuterTwo, 59 | BeforeEachType.InnerOne, BeforeEachType.InnerTwo, BeforeEachType.InnerThree, 60 | ] 61 | XCTAssertEqual(beforeEachOrder, expectedOrder) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/BeforeSuiteTests+Objc.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | #import "QCKSpecRunner.h" 6 | 7 | static BOOL beforeSuiteWasExecuted = NO; 8 | 9 | QuickSpecBegin(FunctionalTests_BeforeSuite_BeforeSuiteSpec) 10 | 11 | beforeSuite(^{ 12 | beforeSuiteWasExecuted = YES; 13 | }); 14 | 15 | QuickSpecEnd 16 | 17 | QuickSpecBegin(FunctionalTests_BeforeSuite_Spec) 18 | 19 | it(@"is executed after beforeSuite", ^{ 20 | expect(@(beforeSuiteWasExecuted)).to(beTruthy()); 21 | }); 22 | 23 | QuickSpecEnd 24 | 25 | @interface BeforeSuiteTests : XCTestCase; @end 26 | 27 | @implementation BeforeSuiteTests 28 | 29 | - (void)testBeforeSuiteIsExecutedBeforeAnyExamples { 30 | // Execute the spec with an assertion before the one with a beforeSuite 31 | NSArray *specs = @[ 32 | [FunctionalTests_BeforeSuite_Spec class], 33 | [FunctionalTests_BeforeSuite_BeforeSuiteSpec class] 34 | ]; 35 | XCTestRun *result = qck_runSpecs(specs); 36 | XCTAssert(result.hasSucceeded); 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/BeforeSuiteTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Quick 3 | import Nimble 4 | 5 | var beforeSuiteWasExecuted = false 6 | 7 | class FunctionalTests_BeforeSuite_BeforeSuiteSpec: QuickSpec { 8 | override func spec() { 9 | beforeSuite { 10 | beforeSuiteWasExecuted = true 11 | } 12 | } 13 | } 14 | 15 | class FunctionalTests_BeforeSuite_Spec: QuickSpec { 16 | override func spec() { 17 | it("is executed after beforeSuite") { 18 | expect(beforeSuiteWasExecuted).to(beTruthy()) 19 | } 20 | } 21 | } 22 | 23 | class BeforeSuiteTests: XCTestCase { 24 | func testBeforeSuiteIsExecutedBeforeAnyExamples() { 25 | // Execute the spec with an assertion before the one with a beforeSuite 26 | let specs = NSArray(objects: FunctionalTests_BeforeSuite_Spec.classForCoder(), 27 | FunctionalTests_BeforeSuite_BeforeSuiteSpec.classForCoder()) 28 | let result = qck_runSpecs(specs) 29 | 30 | XCTAssert(result.hasSucceeded) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/Configuration/AfterEach/Configuration+AfterEach.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | 3 | public var FunctionalTests_Configuration_AfterEachWasExecuted = false 4 | 5 | class FunctionalTests_Configuration_AfterEach: QuickConfiguration { 6 | override class func configure(configuration: Configuration) { 7 | configuration.afterEach { 8 | FunctionalTests_Configuration_AfterEachWasExecuted = true 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/Configuration/AfterEach/Configuration+AfterEachTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Quick 3 | import Nimble 4 | 5 | class Configuration_AfterEachSpec: QuickSpec { 6 | override func spec() { 7 | beforeEach { 8 | FunctionalTests_Configuration_AfterEachWasExecuted = false 9 | } 10 | it("is executed before the configuration afterEach") { 11 | expect(FunctionalTests_Configuration_AfterEachWasExecuted).to(beFalsy()) 12 | } 13 | } 14 | } 15 | 16 | class Configuration_AfterEachTests: XCTestCase { 17 | override func setUp() { 18 | super.setUp() 19 | FunctionalTests_Configuration_AfterEachWasExecuted = false 20 | } 21 | 22 | override func tearDown() { 23 | FunctionalTests_Configuration_AfterEachWasExecuted = false 24 | super.tearDown() 25 | } 26 | 27 | func testExampleIsRunAfterTheConfigurationBeforeEachIsExecuted() { 28 | qck_runSpec(Configuration_BeforeEachSpec.classForCoder()) 29 | XCTAssert(FunctionalTests_Configuration_AfterEachWasExecuted) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/Configuration/BeforeEach/Configuration+BeforeEach.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | 3 | public var FunctionalTests_Configuration_BeforeEachWasExecuted = false 4 | 5 | class FunctionalTests_Configuration_BeforeEach: QuickConfiguration { 6 | override class func configure(configuration: Configuration) { 7 | configuration.beforeEach { 8 | FunctionalTests_Configuration_BeforeEachWasExecuted = true 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/Configuration/BeforeEach/Configuration+BeforeEachTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Quick 3 | import Nimble 4 | 5 | class Configuration_BeforeEachSpec: QuickSpec { 6 | override func spec() { 7 | it("is executed after the configuration beforeEach") { 8 | expect(FunctionalTests_Configuration_BeforeEachWasExecuted).to(beTruthy()) 9 | } 10 | } 11 | } 12 | 13 | class Configuration_BeforeEachTests: XCTestCase { 14 | override func setUp() { 15 | super.setUp() 16 | FunctionalTests_Configuration_BeforeEachWasExecuted = false 17 | } 18 | 19 | override func tearDown() { 20 | FunctionalTests_Configuration_BeforeEachWasExecuted = false 21 | super.tearDown() 22 | } 23 | 24 | func testExampleIsRunAfterTheConfigurationBeforeEachIsExecuted() { 25 | qck_runSpec(Configuration_BeforeEachSpec.classForCoder()) 26 | XCTAssert(FunctionalTests_Configuration_BeforeEachWasExecuted) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/FailureTests+ObjC.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import 4 | #import 5 | 6 | #import "QCKSpecRunner.h" 7 | 8 | static BOOL isRunningFunctionalTests = NO; 9 | 10 | #pragma mark - Spec 11 | 12 | QuickSpecBegin(FunctionalTests_FailureSpec) 13 | 14 | describe(@"a group of failing examples", ^{ 15 | it(@"passes", ^{ 16 | expect(@YES).to(beTruthy()); 17 | }); 18 | 19 | it(@"fails (but only when running the functional tests)", ^{ 20 | expect(@(isRunningFunctionalTests)).to(beFalsy()); 21 | }); 22 | 23 | it(@"fails again (but only when running the functional tests)", ^{ 24 | expect(@(isRunningFunctionalTests)).to(beFalsy()); 25 | }); 26 | }); 27 | 28 | QuickSpecEnd 29 | 30 | #pragma mark - Test Helpers 31 | 32 | /** 33 | Run the functional tests within a context that causes two test failures 34 | and return the result. 35 | */ 36 | static XCTestRun *qck_runFailureSpec(void) { 37 | isRunningFunctionalTests = YES; 38 | XCTestRun *result = qck_runSpec([FunctionalTests_FailureSpec class]); 39 | isRunningFunctionalTests = NO; 40 | 41 | return result; 42 | } 43 | 44 | #pragma mark - Tests 45 | 46 | @interface FailureTests : XCTestCase; @end 47 | 48 | @implementation FailureTests 49 | 50 | - (void)testFailureSpecHasSucceededIsFalse { 51 | XCTestRun *result = qck_runFailureSpec(); 52 | XCTAssertFalse(result.hasSucceeded); 53 | } 54 | 55 | - (void)testFailureSpecExecutedAllExamples { 56 | XCTestRun *result = qck_runFailureSpec(); 57 | XCTAssertEqual(result.executionCount, 3); 58 | } 59 | 60 | - (void)testFailureSpecFailureCountIsEqualToTheNumberOfFailingExamples { 61 | XCTestRun *result = qck_runFailureSpec(); 62 | XCTAssertEqual(result.failureCount, 2); 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/ItTests+ObjC.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | #import "QCKSpecRunner.h" 6 | #import "Quick/Quick-Swift.h" 7 | 8 | QuickSpecBegin(FunctionalTests_ItSpec) 9 | 10 | __block ExampleMetadata *exampleMetadata = nil; 11 | 12 | beforeEach(^{ 13 | exampleMetadata = [[World sharedWorld] currentExampleMetadata]; 14 | }); 15 | 16 | it(@" ", ^{ 17 | expect(exampleMetadata.example.name).to(equal(@" ")); 18 | }); 19 | 20 | it(@"has a description with セレクター名に使えない文字が入っている 👊💥", ^{ 21 | NSString *name = @"has a description with セレクター名に使えない文字が入っている 👊💥"; 22 | expect(exampleMetadata.example.name).to(equal(name)); 23 | }); 24 | 25 | QuickSpecEnd 26 | 27 | @interface ItTests : XCTestCase; @end 28 | 29 | @implementation ItTests 30 | 31 | - (void)testAllExamplesAreExecuted { 32 | XCTestRun *result = qck_runSpec([FunctionalTests_ItSpec class]); 33 | XCTAssertEqual(result.executionCount, 2); 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/ItTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Quick 3 | import Nimble 4 | 5 | class FunctionalTests_ItSpec: QuickSpec { 6 | override func spec() { 7 | var exampleMetadata: ExampleMetadata? 8 | beforeEach { (metadata: ExampleMetadata) in exampleMetadata = metadata } 9 | 10 | it("") { 11 | expect(exampleMetadata!.example.name).to(equal("")) 12 | } 13 | 14 | it("has a description with セレクター名に使えない文字が入っている 👊💥") { 15 | let name = "has a description with セレクター名に使えない文字が入っている 👊💥" 16 | expect(exampleMetadata!.example.name).to(equal(name)) 17 | } 18 | } 19 | } 20 | 21 | class ItTests: XCTestCase { 22 | func testAllExamplesAreExecuted() { 23 | let result = qck_runSpec(FunctionalTests_ItSpec.classForCoder()) 24 | XCTAssertEqual(result.executionCount, 2 as UInt) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/PendingTests+ObjC.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | #import "QCKSpecRunner.h" 6 | 7 | static NSUInteger oneExampleBeforeEachExecutedCount = 0; 8 | static NSUInteger onlyPendingExamplesBeforeEachExecutedCount = 0; 9 | 10 | QuickSpecBegin(FunctionalTests_PendingSpec) 11 | 12 | pending(@"an example that will not run", ^{ 13 | expect(@YES).to(beFalsy()); 14 | }); 15 | 16 | describe(@"a describe block containing only one enabled example", ^{ 17 | beforeEach(^{ oneExampleBeforeEachExecutedCount += 1; }); 18 | it(@"an example that will run", ^{}); 19 | pending(@"an example that will not run", ^{}); 20 | }); 21 | 22 | describe(@"a describe block containing only pending examples", ^{ 23 | beforeEach(^{ onlyPendingExamplesBeforeEachExecutedCount += 1; }); 24 | pending(@"an example that will not run", ^{}); 25 | }); 26 | 27 | QuickSpecEnd 28 | 29 | @interface PendingTests : XCTestCase; @end 30 | 31 | @implementation PendingTests 32 | 33 | - (void)setUp { 34 | [super setUp]; 35 | oneExampleBeforeEachExecutedCount = 0; 36 | onlyPendingExamplesBeforeEachExecutedCount = 0; 37 | } 38 | 39 | - (void)tearDown { 40 | oneExampleBeforeEachExecutedCount = 0; 41 | onlyPendingExamplesBeforeEachExecutedCount = 0; 42 | [super tearDown]; 43 | } 44 | 45 | - (void)testAnOtherwiseFailingExampleWhenMarkedPendingDoesNotCauseTheSuiteToFail { 46 | XCTestRun *result = qck_runSpec([FunctionalTests_PendingSpec class]); 47 | XCTAssert(result.hasSucceeded); 48 | } 49 | 50 | - (void)testBeforeEachOnlyRunForEnabledExamples { 51 | qck_runSpec([FunctionalTests_PendingSpec class]); 52 | XCTAssertEqual(oneExampleBeforeEachExecutedCount, 1); 53 | } 54 | 55 | - (void)testBeforeEachDoesNotRunForContextsWithOnlyPendingExamples { 56 | qck_runSpec([FunctionalTests_PendingSpec class]); 57 | XCTAssertEqual(onlyPendingExamplesBeforeEachExecutedCount, 0); 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/PendingTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Quick 3 | import Nimble 4 | 5 | var oneExampleBeforeEachExecutedCount = 0 6 | var onlyPendingExamplesBeforeEachExecutedCount = 0 7 | 8 | class FunctionalTests_PendingSpec: QuickSpec { 9 | override func spec() { 10 | xit("an example that will not run") { 11 | expect(true).to(beFalsy()) 12 | } 13 | 14 | describe("a describe block containing only one enabled example") { 15 | beforeEach { oneExampleBeforeEachExecutedCount += 1 } 16 | it("an example that will run") {} 17 | pending("an example that will not run") {} 18 | } 19 | 20 | describe("a describe block containing only pending examples") { 21 | beforeEach { onlyPendingExamplesBeforeEachExecutedCount += 1 } 22 | pending("an example that will not run") {} 23 | } 24 | } 25 | } 26 | 27 | class PendingTests: XCTestCase { 28 | override func setUp() { 29 | super.setUp() 30 | oneExampleBeforeEachExecutedCount = 0 31 | onlyPendingExamplesBeforeEachExecutedCount = 0 32 | } 33 | 34 | override func tearDown() { 35 | oneExampleBeforeEachExecutedCount = 0 36 | onlyPendingExamplesBeforeEachExecutedCount = 0 37 | super.tearDown() 38 | } 39 | 40 | func testAnOtherwiseFailingExampleWhenMarkedPendingDoesNotCauseTheSuiteToFail() { 41 | let result = qck_runSpec(FunctionalTests_PendingSpec.classForCoder()) 42 | XCTAssert(result.hasSucceeded) 43 | } 44 | 45 | func testBeforeEachOnlyRunForEnabledExamples() { 46 | qck_runSpec(FunctionalTests_PendingSpec.classForCoder()) 47 | XCTAssertEqual(oneExampleBeforeEachExecutedCount, 1) 48 | } 49 | 50 | func testBeforeEachDoesNotRunForContextsWithOnlyPendingExamples() { 51 | qck_runSpec(FunctionalTests_PendingSpec.classForCoder()) 52 | XCTAssertEqual(onlyPendingExamplesBeforeEachExecutedCount, 0) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/SharedExamples+BeforeEachTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Quick 3 | import Nimble 4 | 5 | var specBeforeEachExecutedCount = 0 6 | var sharedExamplesBeforeEachExecutedCount = 0 7 | 8 | class FunctionalTests_SharedExamples_BeforeEachTests_SharedExamples: QuickConfiguration { 9 | override class func configure(configuration: Configuration) { 10 | sharedExamples("a group of three shared examples with a beforeEach") { 11 | beforeEach { sharedExamplesBeforeEachExecutedCount += 1 } 12 | it("passes once") {} 13 | it("passes twice") {} 14 | it("passes three times") {} 15 | } 16 | } 17 | } 18 | 19 | class FunctionalTests_SharedExamples_BeforeEachSpec: QuickSpec { 20 | override func spec() { 21 | beforeEach { specBeforeEachExecutedCount += 1 } 22 | it("executes the spec beforeEach once") {} 23 | itBehavesLike("a group of three shared examples with a beforeEach") 24 | } 25 | } 26 | 27 | class SharedExamples_BeforeEachTests: XCTestCase { 28 | override func setUp() { 29 | super.setUp() 30 | specBeforeEachExecutedCount = 0 31 | sharedExamplesBeforeEachExecutedCount = 0 32 | } 33 | 34 | override func tearDown() { 35 | specBeforeEachExecutedCount = 0 36 | sharedExamplesBeforeEachExecutedCount = 0 37 | super.tearDown() 38 | } 39 | 40 | func testBeforeEachOutsideOfSharedExamplesExecutedOnceBeforeEachExample() { 41 | qck_runSpec(FunctionalTests_SharedExamples_BeforeEachSpec.classForCoder()) 42 | XCTAssertEqual(specBeforeEachExecutedCount, 4) 43 | } 44 | 45 | func testBeforeEachInSharedExamplesExecutedOnceBeforeEachSharedExample() { 46 | qck_runSpec(FunctionalTests_SharedExamples_BeforeEachSpec.classForCoder()) 47 | XCTAssertEqual(sharedExamplesBeforeEachExecutedCount, 3) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/SharedExamplesTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Quick 3 | import Nimble 4 | 5 | class FunctionalTests_SharedExamples_Spec: QuickSpec { 6 | override func spec() { 7 | itBehavesLike("a group of three shared examples") 8 | } 9 | } 10 | 11 | class FunctionalTests_SharedExamples_ContextSpec: QuickSpec { 12 | override func spec() { 13 | itBehavesLike("shared examples that take a context") { ["callsite": "SharedExamplesSpec"] } 14 | } 15 | } 16 | 17 | // Shared examples are defined in QuickTests/Fixtures 18 | class SharedExamplesTests: XCTestCase { 19 | func testAGroupOfThreeSharedExamplesExecutesThreeExamples() { 20 | let result = qck_runSpec(FunctionalTests_SharedExamples_Spec.classForCoder()) 21 | XCTAssert(result.hasSucceeded) 22 | XCTAssertEqual(result.executionCount, 3 as UInt) 23 | } 24 | 25 | func testSharedExamplesWithContextPassContextToExamples() { 26 | let result = qck_runSpec(FunctionalTests_SharedExamples_ContextSpec.classForCoder()) 27 | XCTAssert(result.hasSucceeded) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/FunctionalTests/WorldExampleMetadataFunctionalTests.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | 4 | class WorldExampleMetadataFunctionalTests: QuickSpec { 5 | override func spec() { 6 | 7 | describe("World metadata") { 8 | it("provides the name of the current example") { 9 | let metadata = World.sharedWorld().currentExampleMetadata! 10 | expect(metadata.example.name).to(equal("World metadata, provides the name of the current example")) 11 | } 12 | } 13 | 14 | it("should have the correct file as the callsite"){ 15 | let file: String = __FILE__ 16 | 17 | let metadata = World.sharedWorld().currentExampleMetadata! 18 | expect(metadata.example.callsite.file).to(equal(file)) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/Helpers/QCKSpecRunner.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | /** 4 | Runs an XCTestSuite instance containing only the given XCTestCase subclass. 5 | Use this to run QuickSpec subclasses from within a set of unit tests. 6 | 7 | Due to implicit dependencies in _XCTFailureHandler, this function raises an 8 | exception when used in Swift to run a failing test case. 9 | 10 | @param specClass The class of the spec to be run. 11 | @return An XCTestRun instance that contains information such as the number of failures, etc. 12 | */ 13 | extern XCTestRun *qck_runSpec(Class specClass); 14 | 15 | /** 16 | Runs an XCTestSuite instance containing the given XCTestCase subclasses, in the order provided. 17 | See the documentation for `qck_runSpec` for more details. 18 | 19 | @param specClasses An array of QuickSpec classes, in the order they should be run. 20 | @return An XCTestRun instance that contains information such as the number of failures, etc. 21 | */ 22 | extern XCTestRun *qck_runSpecs(NSArray *specClasses); 23 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/Helpers/QCKSpecRunner.m: -------------------------------------------------------------------------------- 1 | #import "QCKSpecRunner.h" 2 | #import "XCTestObservationCenter.h" 3 | 4 | #import 5 | 6 | XCTestRun *qck_runSuite(XCTestSuite *suite) { 7 | [World sharedWorld].isRunningAdditionalSuites = YES; 8 | 9 | __block XCTestRun *result = nil; 10 | [[XCTestObservationCenter sharedObservationCenter] _suspendObservationForBlock:^{ 11 | result = [suite run]; 12 | }]; 13 | return result; 14 | } 15 | 16 | XCTestRun *qck_runSpec(Class specClass) { 17 | return qck_runSuite([XCTestSuite testSuiteForTestCaseClass:specClass]); 18 | } 19 | 20 | XCTestRun *qck_runSpecs(NSArray *specClasses) { 21 | XCTestSuite *suite = [XCTestSuite testSuiteWithName:@"MySpecs"]; 22 | for (Class specClass in specClasses) { 23 | [suite addTest:[XCTestSuite testSuiteForTestCaseClass:specClass]]; 24 | } 25 | 26 | return qck_runSuite(suite); 27 | } 28 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/Helpers/QuickTestsBridgingHeader.h: -------------------------------------------------------------------------------- 1 | #import "QCKSpecRunner.h" 2 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/Helpers/XCTestObservationCenter.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | /** 4 | Expose internal XCTest class and methods in order to run isolated XCTestSuite 5 | instances while the QuickTests test suite is running. 6 | 7 | If an Xcode upgrade causes QuickTests to crash when executing, or for tests to fail 8 | with the message "Timed out waiting for IDE barrier message to complete", it is 9 | likely that this internal interface has been changed. 10 | */ 11 | @interface XCTestObservationCenter : NSObject 12 | 13 | /** 14 | Returns the global instance of XCTestObservationCenter. 15 | */ 16 | + (instancetype)sharedObservationCenter; 17 | 18 | /** 19 | Suspends test suite observation for the duration that the block is executing. 20 | Any test suites that are executed within the block do not generate any log output. 21 | Failures are still reported. 22 | 23 | Use this method to run XCTestSuite objects while another XCTestSuite is running. 24 | Without this method, tests fail with the message: "Timed out waiting for IDE 25 | barrier message to complete". 26 | */ 27 | - (void)_suspendObservationForBlock:(void (^)(void))block; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | io.quick.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Vendor/Quick/QuickTests/QuickConfigurationTests.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface QuickConfigurationTests : XCTestCase; @end 5 | 6 | @implementation QuickConfigurationTests 7 | 8 | - (void)testInitThrows { 9 | XCTAssertThrowsSpecificNamed([QuickConfiguration new], NSException, NSInternalInconsistencyException); 10 | } 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /Vendor/Quick/Rakefile: -------------------------------------------------------------------------------- 1 | def run(command) 2 | system(command) or raise "RAKE TASK FAILED: #{command}" 3 | end 4 | 5 | namespace "test" do 6 | desc "Run unit tests for all iOS targets" 7 | task :ios do |t| 8 | run "xcodebuild -workspace Quick.xcworkspace -scheme Quick-iOS clean test" 9 | end 10 | 11 | desc "Run unit tests for all OS X targets" 12 | task :osx do |t| 13 | run "xcodebuild -workspace Quick.xcworkspace -scheme Quick-OSX clean test" 14 | end 15 | end 16 | 17 | namespace "templates" do 18 | install_dir = File.expand_path("~/Library/Developer/Xcode/Templates/File Templates/Quick") 19 | src_dir = File.expand_path("../Quick Templates", __FILE__) 20 | 21 | desc "Install Quick templates" 22 | task :install do 23 | if File.exists? install_dir 24 | raise "RAKE TASK FAILED: Quick templates are already installed at #{install_dir}" 25 | else 26 | mkdir_p install_dir 27 | cp_r src_dir, install_dir 28 | end 29 | end 30 | 31 | desc "Uninstall Quick templates" 32 | task :uninstall do 33 | rm_rf install_dir 34 | end 35 | end 36 | 37 | task default: ["test:ios", "test:osx"] 38 | 39 | --------------------------------------------------------------------------------