Latest 0.1.0
Homepage https://github.com/phatblat/Outlets
License MIT
Platforms ios 8.0
Frameworks UIKit
Authors

Version
License
Platform
Build Status
codecov

Outlets provides a set of functions which validate that IBOutlets are
correctly connected between your Storyboard/XIB file and view controller properties. It
can also validate that IBAction methods are connected correctly as well.

For an explanation of the approach and how these assertions work see
Testing IBOutlets and IBActions With Curried Functions in Swift

Example

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

Here is an example of using Outlets with Quick and Nimble:

class ViewControllerSpec: QuickSpec {
    override func spec() {
        setupFailHandler { message in
            if let message = message {
                fail(message)
            } else {
                fail()
            }
        }

        var viewController: UIViewController!

        var hasBarButtonItemOutlet: BarButtonItemOutletAssertion!
        var hasSegmentedControlOutlet: SegmentedControlOutletAssertion!
        var receivesAction: ActionAssertion!

        describe("view controller") {
            beforeEach {
                viewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ViewController")
                viewController.loadView()
                expect(viewController.view).toNot(beNil())

                setupActionValidator { target, action, expectedAction in
                    expect(target) === viewController
                    expect(action).toNot(beNil())
                    if let action = action {
                        expect(action) == expectedAction
                    }
                }

                // Capture the new viewController instance for each test
                hasBarButtonItemOutlet = outlet(viewController)
                hasSegmentedControlOutlet = outlet(viewController)
                receivesAction = action(viewController)
            }

            // MARK: - Outlets
            it("has a leftButton outlet") {
                hasBarButtonItemOutlet("leftButton")
            }
            it("has a rightButton outlet") {
                hasBarButtonItemOutlet("rightButton")
            }
            it("has a segmentedControl outlet") {
                hasSegmentedControlOutlet("segmentedControl")
            }

            // MARK: - Actions
            it("receives a didTapLeftButton: action from leftButton") {
                receivesAction("didTapLeftButton:", from: "leftButton")
            }
            it("receives a didTapRightButton: action from rightButton") {
                receivesAction("didTapRightButton:", from: "rightButton")
            }
            it("receives a segmentedControlValueDidChange: action from segmentedControl") {
                receivesAction("segmentedControlValueDidChange:", from: "segmentedControl")
            }
        }
    }
}

Requirements

  • Xcode 7.3+
  • CocoaPods 0.39+

Installation

Outlets is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "Outlets"

Author

Ben Chatelain, @phatblat

License

This repo is licensed under the MIT License. See the LICENSE file for rights and limitations.

Latest podspec

{
    "name": "Outlets",
    "version": "0.1.0",
    "summary": "Utility functions for validating IBOutlet and IBAction connections.",
    "description": "Outlets provides a set of functions to make validating that `IBOutlets` arenconnected between your Storyboard/XIB file and view controller properties. Itncan also validate that `IBAction` methods are connected correctly as well.nnFor an explanation of the approach and how these assertions work seen[Testing IBOutlets and IBActions With Curried Functions in Swift](http://phatbl.at/2016/04/29/testing-iboutlets-and-ibactions-with-curried-functions-in-swift.html)nnThe standalonen[OutletActionAssertion](https://github.com/phatblat/OutletActionAssertion)nproject demonstrates how they work.",
    "homepage": "https://github.com/phatblat/Outlets",
    "screenshots": "http://phatbl.at/images/outlet-action-tests-pass.png",
    "license": "MIT",
    "authors": {
        "Ben Chatelain": "[email protected]"
    },
    "source": {
        "git": "https://github.com/phatblat/Outlets.git",
        "tag": "0.1.0"
    },
    "social_media_url": "https://twitter.com/phatblat",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Outlets/Source/**/*",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This