├── .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